Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Fixed-point arithmetic
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Decimal fixed point multiplication=== Suppose there is the following multiplication with two fixed-point, 3-decimal-place numbers. :<math>\begin{align} (10.500)(1.050) &=1 \times 10.500 + 0.050 \times 10.500 \\ &= 10.500+0.525000=11.025000 \end{align}</math> Note how since there are 3 decimal places we show the trailing zeros. To re-characterize this as an integer multiplication we must first multiply by <math>1000\ (=10^3)</math> moving all the decimal places in to integer places, then we will multiply by <math>1/1000\ (=10^{-3})</math> to put them back the equation now looks like :<math>\begin{align} (10.500)(10^{3}) (1.050)(10^{3}) (10^{-3})(10^{-3}) &= (10500)(1050) (10^{-6}) \\ &= 11\,025\,000 (10^{-6}) \\ &= 11.025000 \end{align}</math> This works equivalently if we choose a different base, notably base 2 for computing since a bit shift is the same as a multiplication or division by an order of 2. Three decimal digits is equivalent to about 10 binary digits, so we should round 0.05 to 10 bits after the binary point. The closest approximation is then 0.0000110011. :<math>\begin{align} 10&= 8+2=2^3+2^1\\ 1&=2^0\\ 0.5&= 2^{-1}\\ 0.05&= 0.0000110011_2 \end{align}</math> Thus our multiplication becomes :<math>\begin{align} (1010.100)(2^3)(1.0000110011)(2^{10}) (2^{-13}) &=(1010100)(10000110011) (2^{-13})\\ &=(10110000010111100) (2^{-13})\\ &=1011.0000010111100 \end{align}</math> This rounds to 11.023 with three digits after the decimal point.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)