Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
data conversion
Posted:
Apr 7, 2011 3:35 PM
|
|
hi all, i am getting some problem in data conversion if i give the hex string like 'C34D' the output is 3.3 x=hex2dec('C34D'); exp=(-2*bitget(x,16)+1)*(bitcmp(bitshift(x,-11),5)+1) mant=bitand(hex2dec('3ff'),x) v=mant*2^exp V=3.3 C34D =11000 01101001101 here first five bits N = 11000 = -8 and remaining 11 bits mantissa Y= 845 i used this formula X=Y.2^N to solve the upper equation. here the N value is always binary signed integer
it is working fine. if i give the input as 3.3 how to get it back my hex string like 'C34D' always Ymax = 1023;
and X= 3.3 % given value ymax/X = 1023/3.3 = 310 ;
max(2^-N) <310 ==> 256;
here N = -8 = 11000b
===> X*2^-N == 3.3*2^8 ==844.8 ==845 ==> 01101001101 ==>Y if i combined two bytes it will get hex string
like 1100001101001101 = C34D
how can i get it.. plz help me..
|
|
|
|