Changes between Version 2 and Version 3 of IntroductionToFixedPointMath

Show
Ignore:
Timestamp:
05/15/06 22:04:33 (13 years ago)
Comment:

--

Unmodified
Removed
Modified
• IntroductionToFixedPointMath

v2 v3
227227Well, that all makes sense, but we're assuming that A and B are of the same fractional precision, and what if they're not? Now it's time to look at the "real" math of a fixed point division. Again, this is grade school stuff:
228228
229http://bookofhook.com/Images/Fixed_Point_Images/div_1.gif
230
229231What this says is that if you take two fixed point numbers of m and n fractional bits, and divide them, the quotient will be a value with m-n fractional bits. With our previous example of 16.16 divided by a 16.16, that means 0 fractional bits, which is precisely what we got. If we want to have f fractional bits, we must scale the numerator by 2^f^-(m-n). Since of order operations matters when performing integer operations, we want to scale the numerator before we do the divide, so our final equation looks like:
230232
233http://bookofhook.com/Images/Fixed_Point_Images/div_2.gif
234
231235Order of operations matters, so actual evaluation would use the middle form, where the numerator is fully expanded before division. The far right form is just to show what the final result will look like.
232236