IEEE-754 Single Precision Floating-Point
Example: 0x41200000 = 0 100 0001 0 010 0000 0000 ... 0000 b
s e = 130 f = 2
-2
= 0.25
⇒ Case 3 v = (-1
0
)*2
(130-127)
*1.25 = 10.0
s eeeeeeee fffffffffffffffffffffff
031 30 23 22
23 bit mantissa (fraction)8 bit exponent
1 bit sign
Case 1: if e = 255 and f ≠ 0, then v = NaN
Case 2: if e = 255 and f = 0, then v = [(-1)
s
]*infinity
Case 3: if 0 < e < 255, then v = [(-1)
s
]*[2
(e-127)
]*(1.f)
Case 4: if e = 0 and f ≠ 0, then v = [(-1)
s
]*[2
(-126)
]*(0.f)
Case 5: if e = 0 and f = 0, then v = [(-1)
s
]*0
Advantage ⇒ Exponent gives large dynamic range
Disadvantage ⇒ Precision of a number depends on its exponent
Normalized
values
Number Line Insight
Floating-Point:
0
+∞
-∞
0
+∞
-∞
Non-uniform distribution
Precision greatest near zero
Less precision the further you get from zero