IEEE 754 Encoding
The figure below shows the encodings of IEEE 754 floating-point numbers.
Other features of IEEE 754 are special symbols to represent unusual events:
-
Zero
- Zero is represented with exponent
E=0
and fraction F=0
.
-
Infinity (∞)
- Infinity is a special value represented with maximum
E
and F=0
where
- For single precision with 8-bit exponent: maximum
E=255
, and
- For double precision with 11-bit exponent: maximum
E=2047
.
Infinity can result from overflow or division by zero.
±0 and ±∞ are possible according to the sign bit S
.
- NaN (Not a Number)
- NaN is a special value represented with maximum
E
and F≠0
.
It is the result from exceptional situations, such as 0/0 or sqrt(negative)
.
Operation on a NaN is NaN: Op(X,NaN)=NaN
.
Single Precision |
Exponent (8 bits) |
Fraction (23 bits) |
Value |
Normalized numbers |
1 — 254 |
anything |
±(1.F)2 × 2E-127 |
Denormalized numbers |
0 |
non-zero |
±(0.F)2 × 2-126 |
Zero |
0 |
0 |
±0 |
Infinity |
255 |
0 |
±∞ |
NaN (not a number) |
255 |
non-zero |
NaN |
|
Double Precision |
Exponent (11 bits) |
Fraction (52 bits) |
Value |
Normalized numbers |
1 — 2046 |
anything |
±(1.F)2 × 2E-1023 |
Denormalized numbers |
0 |
non-zero |
±(0.F)2 × 2-1022 |
Zero |
0 |
0 |
±0 |
Infinity |
2047 |
0 |
±∞ |
NaN (not a number) |
2047 |
non-zero |
NaN |