Instructor: Joel E. Tohline
tohline@rouge.phys.lsu.edu
Binary Representation of Java [float] Data Type | |||||
---|---|---|---|---|---|
Decimal Number |
sign bit | 8-bit exponent | 23-bit mantissa | example | |
f | s | e | M | ||
1/2 | = | 0 |
1000 0000 |
100 0000 0000 0000 0000 0000 |
(a) |
3 | = | 0 |
1000 0010 |
110 0000 0000 0000 0000 0000 |
(b) |
1/4 | = | 0 |
0111 1111 |
100 0000 0000 0000 0000 0000 |
(c) |
10-7 | = | 0 |
0110 1001 |
110 1011 0101 1111 1100 1010 |
(d) |
= | 0 |
1000 0010 |
000 0000 0000 0000 0000 0000 |
(e) | |
3 + 10-7 | = | 0 |
1000 0010 |
110 0000 0000 0000 0000 0000 |
(f) |
These examples have been taken directly from Figure 1.2.1 of the "Numerical Recipes" textbook. The correct (decimal) number "f" is actually derived from the tabulated information as follows:
where, B = 2 (base 2 arithmetic) and E = 151 (the bias) = 128 + 23.