Computer number format: Difference between revisions

Content deleted Content added
m Reverted 1 edit by 191.91.246.208 (talk) to last revision by 209.35.193.1
 
(17 intermediate revisions by 15 users not shown)
Line 147:
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"
Line 189:
* a sign bit, giving the sign of the number.
 
Let'sWith seethe what this format looks like by showing how such a number would bebits stored in 8 bytes of memory:
 
{| class="wikitable"
Line 288:
The representation has a limited precision. For example, only 15 decimal digits can be represented with a 64-bit real. If a very small floating-point number is added to a large one, the result is just the large one. The small number was too small to even show up in 15 or 16 digits of resolution, and the computer effectively discards it. Analyzing the effect of limited precision is a well-studied problem. Estimates of the magnitude of round-off errors and methods to limit their effect on large calculations are part of any large computation project. The precision limit is different from the range limit, as it affects the significand, not the exponent.
 
The significand is a binary fraction that doesn't necessarily perfectly match a decimal fraction. In many cases a sum of reciprocal powers of 2 does not match a specific decimal fraction, and the results of computations will be slightly off. For example, the decimal fraction "0.1" is equivalent to an infinitely repeating binary fraction: 0.000110011 ...<ref>{{cite web|last=Goebel|first=Greg|title=Computer Numbering Format|url=http://www.vectorsite.net/tsfloat.html|archive-url=https://archive.today/20130222091425/http://www.vectorsite.net/tsfloat.html|url-status=usurped|archive-date=February 22, 2013|access-date=10 September 2012}}</ref>
 
==Numbers in programming languages==
Line 306:
* [[Gray code]]
* [[Numeral system]]
* [[Unum (number format)|Unum]]
* [[Posit (number format)|Posit]]
 
==Notes and references==