Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added figure

Java uses 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 * M * 2 E.

Image Added

Ordinarily, all of the mantissa bits are used to express significant figures, in addition to a leading 1, which is implied and consequently omitted. As a result, floats have 24 significant bits of precision, and doubles have 53 significant bits of precision. Such numbers are called normalized numbers.

...