Randy Yates
Guest
|
Posted:
Fri Dec 09, 2005 5:16 pm Post subject:
Re: fixed point - floating point newbie question |
|
|
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 |
|