IEEE Floating Point - Character Representation

Character Representation

The standard requires operations to convert between basic formats and external character sequence formats. Conversions to and from a decimal character format are required for all formats. Conversion to an external character sequence must be such that conversion back using round to even will recover the original number. There is no requirement to preserve the payload of a NaN or signaling NaN, and conversion from the external character sequence may turn a signaling NaN into a quiet NaN.

The original binary value will be preserved by converting to decimal and back again using:

  • 5 decimal digits for binary16
  • 9 decimal digits for binary32
  • 17 decimal digits for binary64
  • 36 decimal digits for binary128

For other binary formats the required number of decimal digits is

1 + ceiling(p×log102)

where p is the number of significant bits in the binary format, e.g. 24 bits for binary32.

(Note: as an implementation limit, correct rounding is only guaranteed for the number of decimal digits above plus 3 for the largest binary format supported. For instance if binary32 is the largest supported binary format supported, then a conversion from a decimal external sequence with 12 decimal digits is guaranteed to be correctly rounded when converted to binary32; but conversion of a sequence of 13 decimal digits is not; however the standard recommends that implementations impose no such limit.)

When using a decimal floating point format the decimal representation will be preserved using:

  • 7 decimal digits for decimal32
  • 16 decimal digits for decimal64
  • 34 decimal digits for decimal128

Algorithms, with code, for correctly rounded conversion from binary to decimal and decimal to binary are discussed in and for testing in.

Read more about this topic:  IEEE Floating Point

Famous quotes containing the word character:

    Whoever has the luck to be born a character can laugh even at death. Because a character will never die! A man will die, a writer, the instrument of creation: but what he has created will never die!
    Luigi Pirandello (1867–1936)