Exponent
- Have 8 bits available (256 values),
need to represent positive and negative exponents
(ideally -127 → 128, not -128 → 127).
- Could use sign & magnitude, one's complement, or two's
complement
BUT we want negative exponents to look smaller
than positive exponents
Significand
Putting it all together - Detailed Example
What value does the 32-bit IEEE floating point number
01000010001101100000000000000000 represent? In other words,
what is the common decimal representation for that number? By the way,
since a single string of 32 bits is hard to read, we often seen it written
in groups of 4 or 8, or written in octal or hex. For example, we could
represent that same binary number as
0100 0010 0011 0110 0000 0000 0000 0000
or
4 2 3 6 0 0 0 0
How do we convert that to a decimal representation we recognize?
- First, change the spacing (which is only for our readability) to
match the parts of a floating point number -- 1 bit for the sign
bit, 8 bits for the exponent, 23 bits for the significand. So, the
binary number above would become
0 10000100 01101100000000000000000
- The sign bit in this case is
0, so the number is positive.
- The exponent bits are the binary for
132
(128 + 4), so the actual
exponent is 132-127 = 5.
- The significand bits are
011011000... . When we add
the implicit 1 before the binary point, we get
1.011011000...
- This gives us
+ 1.011011 * 2^5. We can simplify this
by moving the binary point 5 places to the right, so we get
+101101.1.
101101 = 45 and 0.1 = 1/2, so the final
value for this example would be +45.5.
Can we go the other way?
For example, what is the 32-bit IEEE representation for decimal 45.5?
45.5 = 101101.1 in binary. (Not IEEE floating point,
just regular binary.)
- The sign bit should be
0, because the number is
positive.
101101.1 can be normalized to 1.011011 *
2^5.
- That gives us
0 for the sign bit
5 for the real exponent, or
127+5 = 132 for the IEEE exponent.
132 = 10000100
011011 for the bits after the binary point.
(The 1 to the left of the binary point is implicit (left
out) rather than explicit.)
- The final number is
0 10000100 011011 000... or,
spaced in half-bytes,
0100 0010 0011 0110 0000 0000 0000 0000
- That binary number can also be represented in hex as
4 2 3 6 0 0 0 0
0 is a special case
- 0 cannot be represented as described above — it has no normal
form.
So the IEEE standard represents it as all
0's.
| 31 |
30 23 |
22
0 |
| 0 |
00000000 |
0000000000000000... |
| ↑ |
↑ |
↑ |
| sign |
exp |
significand |
| |
(8 bits) |
(23 bits) |
- Advantages: Very quick tests for
<0, 0,
>0
(S == 1, all zeros, S == 0 but not all zeros)
- Disadvantage: Lose ability to represent
2-127 — small loss!
Examples
45.510 = 101101.12 = 1.011011 * 25
| 31 |
30 23 |
22
0 |
| 0 |
10000100 |
0110110000000000... |
1/8 = 0.0012 = 1.000 * 2-3
| 31 |
30 23 |
22
0 |
| 0 |
01111100 |
0000000000000000... |
Your turn: 34 1/4 = ?
Trick Question: 1/10 = ?
64-bit word
- Same as for 32-bit word, except
both exponent and significand have more bits
and
exp = E + 1023.
| 63 |
62 52 |
51
0 |
| S |
Exp |
Significand |
| ↑ |
↑ |
↑ |
| sign |
exp |
significand |
| |
(11 bits) |
(52 bits) |