hi, i have e.g. number 1 in floating point and its equivalent of 8192 in fixed point representation. what is the connection? how do you calculate this exactly? another example would be -2.000125721 in floating is -16385 in fixed point. please help. thx
fixed point - floating point newbie question
Started by ●December 9, 2005
Reply by ●December 9, 20052005-12-09
Hi, In a nutshell you divide the integer value of (e.g.) 8192 by 2^b, where b is the "scaling" of the fixed-point value. In your case, b must be 13 since 2^13 = 8192 and 8192/8192 = 1.0. In the second example, the scaling of the value is still apparently 13, since -16385/2^13 = -2.00012207, which is approximately equal to your desired floating-point value of -2.000125721. This is a good example because you can begin to see the effect of the choice of b on your results, i.e., that there is an error in the representation, and that the range of the value you wish to represent dictates the scaling (so you don't overflow), which in turn dictates the resolution you will have. I've been meaning to rewrite this for years since it's so long-winded, but the following may help: http://www.digitalsignallabs.com/fp.pdf --Randy Yates