Decimal64 floating-point format: Difference between revisions

Content deleted Content added
Found (and fixed) one value that didn't get converted.
Use template:gaps for large numbers.
Line 3:
It is intended for applications where it is necessary to emulate decimal rounding exactly, such as financial and tax computations.
 
Decimal64 supports 16 [[decimal digit]]s of [[significand]] and an [[exponent]] range of −383 to +384, i.e. {{gaps|±0.000000000000000×10<sup>−383</sup>000|000|000|000|000|e=-383}} to {{gaps|±9.999999999999999×10<sup>999|999|999|999|999|e=384</sup>}}. (Equivalently, {{gaps|±0,|000,|000,|000,|000|000,000×10<sup>−398</sup>|e=-398}} to {{gaps|±9,|999,|999,|999,|999,999×10<sup>|999|e=369</sup>}}.) Because the significand is not normalized, most values with less than 16 [[significant digits]] have multiple possible representations; {{gaps|1×10<sup>2</sup>=|&61;|0.1×10<sup>3</sup>=|&#61;|0.01×10<sup>4</sup>}}, etc. Zero has 768 possible representations (1536 if you include both [[signed zero]]s).
 
Decimal64 floating point is a relatively new decimal floating-point format, formally introduced in the 2008 version of [[IEEE 754]].
Line 47:
 
=== Binary integer significand field ===
This format uses a binary significand from 0 to 10<sup>16</sup>−1 = {{gaps|9,|999,|999,|999,|999,|999}} = 2386F26FC0FFFF<sub>16</sub> =
{{gaps|1000&thinsp;|1110000110&thinsp;|1111001001&thinsp;|1011111100&thinsp;|0000111111&thinsp;|1111111111<sub>2</sub>}}.
The encoding can represent binary significands up to 10×2<sup>50</sup>−1 = {{gaps|11,|258,|999,|068,|426,|239}} = 27FFFFFFFFFFFF<sub>16</sub>, but values larger than 10<sup>16</sup>−1 are illegal (and the standard requires implementations to treat them as 0, if encountered on input).
 
As described above, the encoding varies depending on whether the most significant 4 bits of the significand are in the range 0 to 7 (0000<sub>2</sub> to 0111<sub>2</sub>), or higher (1000<sub>2</sub> or 1001<sub>2</sub>).
Line 73:
values for the binary formats. Note also that the "00", "01", or "10" bits are part of the exponent field.
 
Note that the leading bits of the significand field do ''not'' encode the most significant decimal digit; they are simply part of a larger pure-binary number. For example, a significand of {{gaps|8,|000,|000,|000,|000,|000}} is encoded as binary {{gaps|111&thinsp;|0001101011&thinsp;|1111010100&thinsp;|1001100011&thinsp;|0100000000&thinsp;|0000000000}}, with the leading 4 bits encoding 7; the first significand which requires a 54th bit is 2<sup>53</sup> = {{gaps|9,|007,|199,|254,|740,|992}}.
 
In the above cases, the value represented is