decimalieee-754dataformat

decimal128 ieee 754 combination/exponent


The IEEE 754 decimal128 standard described here shows that it has a 17 bit combination, and a 14 bit exponent.

But in the examples shown, it uses either the upper 2 bits or upper 4 bits of the combination, and those determine the upper two bits to use in the exponent field, as well as the upper 4 bits in the actual significand. This leaves either 15 bits or 13 bits remaining in the combination, and it is unclear from the table on this page which bits from the combination actually go to the 12 lower bits of the exponent, and which bits are copied into the significand.

Some assistance here in understanding this format would be greatly appreciated


Solution

  • While you should refer to an authoritative source, such as the IEEE 754 standard, the Wikipedia page gives you all the information to interpret the format.

    Denote the bits of the encoding by sabcdefghijklmnopqT, where s is the sign bit, a through q are bits of the combination field, and T is the trailing 110 bits.

    The section “Binary integer significand field” tell you how to interpret encodings using a binary significand. It says:

    If the 2 bits after the sign bit are "00", "01", or "10", then the exponent field consists of the 14 bits following the sign bit, and the significand is the remaining 113 bits, with an implicit leading 0 bit…

    Therefore, if ab is 00, 01, or 10, the exponent field is abcdefghijklmn, and the significand bits are 0opqT.

    If the 2 bits after the sign bit are "11", then the 14-bit exponent field is shifted 2 bits to the right (after both the sign bit and the "11" bits thereafter), and the represented significand is in the remaining 111 bits. In this case there is an implicit (that is, not stored) leading 3-bit sequence "100" in the true significand.

    Therefore, if ab is 11 (but excluding the encodings for infinities and NaNs), then the exponent field is cdefghijklmnop and the significand bits are 100qT.

    The section “Densely packed decimal significand field” tells you how to interpret encodings using a DPD significand. It says:

    The leading 2 bits of the exponent and the leading digit (3 or 4 bits) of the significand are combined into the five bits that follow the sign bit.

    This twelve bits after that are the exponent continuation field, providing the less-significant bits of the exponent.

    So the trailing 12 bits of the exponent field are fghijklmnopq. We still need the first two bits of the field.

    If the first two bits after the sign bit are "00", "01", or "10", then those are the leading bits of the exponent, and the three bits after that are interpreted as the leading decimal digit (0 to 7)…

    Therefore, if ab is 00, 01, or 10, the exponent is abfghijklmnopq, and the first significand digit is cde.

    If the first two bits after the sign bit are "11", then the second two bits are the leading bits of the exponent, and the last bit is prefixed with "100" to form the leading decimal digit (8 or 9)…

    Therefore, if ab is 11 (but excluding the encodings for infinities and NaNs), the exponent field is cdfghijklmnopq, and first significand digit is 100e.

    In both of the DPD cases, the remaining significand digits are encoded in T.