Floating-Point Examples
Example I
What is the decimal value of this single-precision floating-point number?
1 |
0 |
1 |
1 |
1 |
1 |
1 |
0 |
0 |
0 |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
Sign = 1 is negative.
Exponent = 011111002 = 22+23+24+25+26 = 4+8+16+32+64 = 124
E-Bias = 124 - 127 = -3
Significand = 1.0100...02 = 1 + 2-2 = 1.25
where 1.0 is implicit.
Therefore, the value in decimal = -1.25 × 2-3 = -0.15625
Example II
What is the decimal value of this single-precision floating-point number?
0 |
1 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
0 |
1 |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
Sign = 0 is positive.
Exponent = 100000102 = 21+27 = 2+128 = 130
E-Bias = 130 - 127 = 3
Significand = 1.01001100...02 = 1+2-2+2-5+2-6
= 1+0.25+0.03125+0.015625 = 1.296875
Therefore, the value in decimal = 1.296875 × 23 = 10.375
Example III
What is the decimal value of this double-precision floating-point number?
0 |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
1 |
0 |
0 |
1 |
0 |
1 |
0 |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
Sign = 0 is positive.
Exponent = 100000001012 = 20+22+210 = 1+4+1024 = 1029
E-Bias = 1029 - 1023 = 6
Significand = 1.00101010...02 = 1+2-3+2-5+2-7
= 1+0.125+0.03125+0.0078125 = 1.1640625
Therefore, the value in decimal = 1.1640625 × 26 = 74.5
Tom stole cameras when he worked here.
I’ll hire him back when hell freezes over (never).
|