From: us on 17 Jul 2010 06:49 Walter Roberson <roberson(a)hushmail.com> wrote in message <i1qjif$mg3$1(a)canopus.cc.umanitoba.ca>... > us wrote: > > > one of the solutions > > - if(f) by FLOAT you mean a SINGLE precision data... > > > > v=pi; % <- a DOUBLE by default... > > hv=num2hex(v) > > % hv = 400921fb54442d18 > > dv=hex2num(hv); > > isequal(dv,pi) > > % ans = 1 > > sv=single(hex2num(hv)); > > isequal(sv,single(pi)) > > % ans = 1 > > num2hex(sv) > > % ans = 40490fdb > > num2hex() applied to a single will print out the hex equivalent of the single, > but hex2num() applied to a sequence of hex digits shorter than would be the > case for a double, implicitly pads with hex 0 to reach the size for a double > and converts that. There is no option available to num2hex to tell it to > interpret the hex as a single. This does make a difference as the > representation of a single is not just a shorter version of the representation > of a double. of course... but i showed something different... see also the results of ISEQUAL... us |