Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Most implementations of C use the IEEE 754 standard for floating point representation. In this representation floats are encoded using 1 sign bit, 8 exponent bits and 23 mantissa bits. Doubles are encoded and used exactly the same way except they use 1 sign bit, 11 exponent bits, and 52 mantissa bits.These bits encode the values of s, the sign; M, the significand; and E, the exponent. Floating point numbers are then calculated as (-1)^s s * M * 2^E2 E.

Ordinarily all of the mantissa bits are used to express significant figures in addition to a leading 1 which is implied and therefore left out. Thus floats ordinarily have 24 significant bits of precision and doubles ordinarily have 53 significant bits of precision. Such numbers are called normalized numbers. All floating point numbers are limited in this sense that they have fixed precision. FLP00-C. Understand the limitations of floating point numbers.

...

According to ISO/IEC 9899:TC3 §7§7.19.6.1:

A double argument representing a floating-point number is converted in the style ?0xh.hhhh p±dp±d, where there is one hexadecimal digit (which is nonzero if the argument is a normalized floating-point number and is otherwise unspecified) before the decimal-point character

...