Back
Next
Lectures
Converting a real number of float style format.
Start by putting number into binary
Then format in scientific style notation.
Example of a binary real number in scientific notation:
(5.75)
101.11 = 1.0111 * 2^2 (hybrid representation, exponent still decimal)
Stored representation divided into three sub-units
Dedicated Sign bit 0 = + 1 = -
Exponent to what power is 2 raised (also needs to handle sign).
Significant digits known as the significand
Sign bit
high bit of float storage set to :
0 for positive number
1 for negative number
Calculating Bias and biasing the exponent to handle sign.
Reasoning behind biasing the exponent.
Remember all zeros or all 1's in the exponent are flag conditions, So we
need a number sequence in which all zeros and all ones occur on either
end of the range of possible exponent values.
But the range itself can still represent both positive and negative
exponents.
Assume a 3 bit exponent,
Normal signed integer would allow for 100b to 011 or -4 to 3
Normal : | 100 | 101 | 110 | 111 | 000 | 001 | 010 | 011 |
| -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 |
If we slide number line or bias the values so that 000 and 111 are at
the end of our number lines.
Binary : | 000) | 001 | 010 | 011 |
100 | 101 | 110 | (111 |
Biased : | 0 | 1 | 2 | 3 |
4 | 5 | 6 | 7 |
Represents : | RES. | -2 | -1 | 0 |
1 | 2 | 3 | RES. |
# Using an 8 bit exponent, we would have an initial range of -128 to 127
# And after, biasing, we would have a range of -126 to 127
---
By adding or biasing the range by 3, we get what we want.
Bias formula 2^(n-1) - 1, where n is number of bits in exponent storage.
3 bit exponent bias example :
2^(3-1)-1 = 3 - calculate a working bias.
Now a real zero become 3 when biased, all other values are biased by 3
also. Note that 000 and 111 are at the end of our number lines and we
can treat them as flags
For example above, bias = 3, exponent = 2
biased exponent 3 + 2 = 5 or 101 binary.