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
Computer number format
(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!
===Fixed-point numbers=== [[Fixed-point arithmetic|Fixed-point]] formatting can be useful to represent fractions in binary. The number of bits needed for the precision and range desired must be chosen to store the fractional and integer parts of a number. For instance, using a 32-bit format, 16 bits may be used for the integer and 16 for the fraction. The eight's bit is followed by the four's bit, then the two's bit, then the one's bit. The fractional bits continue the pattern set by the integer bits. The next bit is the half's bit, then the quarter's bit, then the eighth's bit, and so on. For example: {| class="toccolours" |- style="text-align:center" ! || || || || integer bits || fractional bits |- | 0.500 ||=|| {{sfrac|1|2}}||=||colspan=2| 00000000 00000000.10000000 00000000 |- | 1.250 ||=||{{sfrac|1|1|4}}||=||colspan=2| 00000000 00000001.01000000 00000000 |- | 7.375 ||=||{{sfrac|7|3|8}}||=||colspan=2| 00000000 00000111.01100000 00000000 |} This form of encoding cannot represent some values in binary. For example, the fraction {{sfrac|1|5}}, 0.2 in decimal, the closest approximations would be as follows: {| class="toccolours" |- | 13107 / 65536 ||=|| 00000000 00000000.00110011 00110011 ||=|| 0.1999969... in decimal |- | 13108 / 65536 ||=|| 00000000 00000000.00110011 00110100 ||=|| 0.2000122... in decimal |} Even if more digits are used, an exact representation is impossible. The number {{sfrac|1|3}}, written in decimal as 0.333333333..., continues indefinitely. If prematurely terminated, the value would not represent {{sfrac|1|3}} precisely.
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)