Reputation: 956
I've been reading an article by Dr William T. Verts titled An 8-Bit Floating Point Representation where the author defines, as the title suggests, an 8-bit floating point representation with one bit for sign, three bits for exponent and the remaining four bits for the mantissa.
Now, in the article, he writes:
The range of legal exponents (those representing neither denormalized nor infinite numbers) is then between 2^{-2} and 2^{+3}.
I'm confused as to what he means by legal in this context. And, why can't 2^{-3} can't be a 'legal' value? As when 2^{-3} offset by 3, gives 0 which is 000
in the exponent field.
Next, he lists all possible values of numbers representable in this system. I'm attaching the screenshot of the first few denormalized numbers below.
I understand that we cannot represent small numbers in the normalized form, forcing us to detour from the norm and use 0
before the decimal point rather than the usual 1
, which gives us what we call a denormalized form.
But, why are we using -2
in the exponent of 2
(rather than -3
)?
According to the rules of excess-3, the exponent field should have -2+3=1 which is 001
in the exponent field, but it has 000
in the exponent field instead(it does have 001
in the normalized numbers). But, if we use 2^{-3}
, the exponent field indeed should have 000
as -3+3=0.
A nice summary of my second question would be:
Why are we not using 2^{-3} as the exponent from N=1 to N=15? The exponent field does have 000
which corresponds to -3 as the exponent.
Note: I understand that the nature of the topic itself is pretty confusing. Thus, if there is any vagueness in my question, please point it out in the comments.
Upvotes: 1
Views: 65
Reputation: 222856
But, why are we using
-2
in the exponent of2
(rather than-3
)?
Suppose you did that. With exponent field 0002 for subnormal numbers (leading bit 0) and primary significand1 field values from 00002 to 11112, you could represent the numbers 0.00002•2−3 to 0.11112•2−3. And with exponent field 0012 for normal numbers (leading bit 1) and primary significand field values from 00002 to 11112, you could represent the numbers 1.00002•2−2 to 1.11112•2−2.
Where is 1.00002•2−3? The subnormals stop at 0.11112•2−3, and the normals start at 1.00002•2−2. All the numbers from 1.00002•2−3 to 1.11112•2−3 were skipped.
When you are going down from the lowest subnormal, 1.00002•2−2, you cannot both decrease the exponent and change the leading digit from 1 to 0.
That is why the 0002 exponent code means the same exponent code as 0012. It is a code for changing the leading bit to 0 but using the same exponent as the lowest normals. Which answers your first question too.
The exponent field actually encodes both the exponent and the leading bit of the significand:
Exponent field bits | Meaning |
---|---|
000 | Leading bit 0, exponent −2 |
001 | Leading bit 1, exponent −2 |
010 | Leading bit 1, exponent −1 |
011 | Leading bit 1, exponent 0 |
100 | Leading bit 1, exponent +1 |
101 | Leading bit 1, exponent +2 |
110 | Leading bit 1, exponent +3 |
111 | Infinity or NaN |
1 “Significand” is the preferred term for the fraction part of a floating-point number. “Mantissa” is an old term for the fraction part of a logarithm. Mantissas are logarithmic; adding to the mantissa multiplies the number. Significands are linear; adding to the significand adds to the number (as scaled by the exponent).
Upvotes: 2