Binary integer decimal: Difference between revisions

Content deleted Content added
m Format: typo
Line 19:
 
==Format==
Using the fact that 2<sup>10</sup> = 1024 is only slightly more than 10<sup>3</sup> = 1000, 3''n''-digit decimal numbers can be efficiently packed into 10''n'' binary bits. However, the IEEE formats have signficandssignificands of 3''n''+1 digits, which would generally require 10''n''+4 binary bits to represent.
 
This would not be efficient, because only 10 of the 16 possible values of the additional 4 bits are needed. A more efficient encoding can be designed using the fact that the exponent range is of the form 3×2<sup>''k''</sup>, so the exponent never starts with <code>11</code>. Using the Decimal32 encoding (with a significand of 3*2+1 decimal digits) as an example (<code>e</code> stands for exponent, <code>m</code> for mantissa, i.e. significand):
 
* If the significand starts with <code>0mmm</code>, omitting the leading 0 bit lets the signficandsignificand fit into 23 bits:
s 00eeeeee (0)mmm mmmmmmmmmm mmmmmmmmmm
s 01eeeeee (0)mmm mmmmmmmmmm mmmmmmmmmm