Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Computer number format
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Computer number format
(section)
Add topic