|
|
|
|
|
|
|
|
|
|
|
|
|
|
Floating Point |
|
|
|
|
General form: canonical binary scientific notation |
|
|
|
1.fffftwo * 2eeee |
|
|
|
ffff |
fraction (signficand) |
|
|
|
eeee |
exponent (expressed in decimal
for simplicity) |
|
|
|
Note that both have signs |
|
|
|
|
|
b31 |
b30 b23 |
b22 |
|
b0 |
|
|
s |
e |
f |
|
|
|
IEEE 754 standard |
|
|
|
|
(1985) |
|
|
s (1 bit): sign |
|
|
e (8 bits): exponent |
|
|
|
excess 127 (NOT 128!) |
|
|
|
-126 <= e <= 127 |
|
|
f (23 bits): fraction |
|
|
|
called significand or
mantissa |
|
|
|
assume leading 1
("hidden one") |
|
|
|
|
|
categories of floating
point numbers |
|
|
|
* normalized numbers: standard floating point numbers. |
|
|
|
Most bitstring patterns
in IEEE 754 |
|
|
|
* denormalized numbers: fewer bits of precision, and smaller (in magnitude) |
|
|
than normalized numbers. |
|
|
|
* zero: a positive and negative representation of 0 (sign bit 0 or 1) |
|
|
|
* infinity: also a positive and negative infinity |
|
|
|
For example, 1.0/0.0
produces infinity. |
|
|
|
* NaN: "not a number"; undefined value like sqrt (-4) |
|
|
|
|
|
|
S Exp Fraction |
|
Value |
|
|
|
- ---------
---------------------------- |
|
|
|
|
0 1111 1111 1111 1111
1111 1111 1111 111 |
NaN |
|
|
|
0 1111 1111 0000 0000
0000 0000 0000 001 |
NaN |
|
|
|
0 1111 1111 0000 0000
0000 0000 0000 000 |
Infinity |
|
|
|
0 1111 1110 1111 1111
1111 1111 1111 111 |
1.11 . . . 1 x 2127 |
|
|
|
|
0 1111 1110 0000 0000
0000 0000 0000 000 |
2127 |
|
|
|
0 1000 0000 0000 0000
0000 0000 0000 000 |
21 |
Normalized |
|
|
0 0111 1111 0000 0000
0000 0000 0000 000 |
1 |
|
|
|
0 0111 1110 0000 0000
0000 0000 0000 000 |
2-1 |
|
|
|
0 0000 0001 0000 0000
0000 0000 0000 000 |
2-126 |
|
|
|
0 0000 0000 1111 1111
1111 1111 1111 111 |
0.11 . . . 1 x 2-126 |
|
|
|
|
0 0000 0000 1000 0000
0000 0000 0000 000 |
2-127 |
Denormalized |
|
|
0 0000 0000 0000 0000
0000 0000 0000 001 |
2-149 |
|
|
|
0 0000 0000 0000 0000
0000 0000 0000 000 |
0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|