Bits of a Floating Point Value
The IEEE 754 representation of a floating point value:
- Sign bit is 0 for positive and 1 for negative.
- The exponent is stored with an offset. +127 for single precision and +1023 for double precision.
- The significand implicitly starts with a 1 followed by the binary point.
The value represented is:
Example: Decoding a single precision float:
If all the exponent bits are zero, then −126 (or −1023 for a double) is the actual exponent, and the implicit leading bit of the significand is 0 (instead of 1). See Normal vs Subnormal Floats.
If all the exponent bits are ones, then the value is infinity (if all the significand bits are zero) and NaN (if any significand bit is one).
The sign of a zero value is ignored by all comparison operations (but may still have significance in other situations).
For NaN the sign bit is always ignored.