3
votes

I'm trying to figure out some specifics of using a normalized representation for floating-point values.

As I understand, the IEEE-754 representation works like:

1.{significand} * 2^{exponent}

For single precision, the significand being 24 bits, the exponent being 8 bits.

What I'm trying to break this down to is essentially the number of "slots" available in each range of numbers supported by the exponent, such as:

[Exponent=0] 0.0 - 1.0 : 2^23 values
[Exponent=1] 1.0 - 2.0 : 2^23 values
[Exponent=2] 2.0 - 4.0 : 2^23 values
[Exponent=3] 4.0 - 8.0 : 2^23 values

I'm trying to demonstrate that in using quantisation if the range I'm interested in is limited to 0.0 - 1.0, I can use 2^24 bits to represent this number and there will be no loss of precision in removing the exponent and this can be easily converted to a full floating-point representation. Also, to clearly illustrate the greater precision closer to zero than further away when using floating-point, as it feels like this may be quite intuitive to understand.

One area in particular that I'm not quite clear on is where the supported exponent is -127 to 126, how does the negative portion work? 1.5 * 2^-1 clearly overlaps with the 0.0 - 1.0 range.

Finally, I know that one of the bits in the significand is used for the sign, however what does the hidden bit represent, does this affect the number of "slots" that are available in each range?

1
Note that the mantissa has 24 bits, but since the highest bit is always set for normalised numbers, and always cleared for de-normalised numbers, it is not stored. 23 bits of the mantissa are stored. - gnasher729
To answer the “use 2^24 bits to represent this number and there will be no loss of precision” part of your question, there are plenty of floating-point numbers between 0 and 0.5 that cannot be represented without loss in the 24-bit fixed-point format that you appear to be considering. - Pascal Cuoq
You have your exponent range a bit mixed up: normal numbers will have an (unbiased) exponent between -126 and 127 inclusive (corresponding to the 8 bits of the biased exponent field ranging between 1 and 254). An exponent field of 0 is reserved for zeros and subnormals, while an exponent field of 255 is reserved for infinities and NaNs. - Mark Dickinson
There aren't 2^23 values between 0.0 and 1.0: There are 2^23 between 0.5 and 1.0, 2^23 between 0.25 and 0.5, 2^23 between 0.125 and 0.25, and so on, and so on until you get down to the denormalized numbers. - Solomon Slow

1 Answers

3
votes

Your table is wrong, I think. It should be:

....
[Exponent=-3] 0.125 - 0.25 : 223 values
[Exponent=-2] 0.25 - 0.5 : 223 values
[Exponent=-1] 0.5 - 1.0 : 223 values
[Exponent=0] 1.0 - 2.0 : 223 values
[Exponent=1] 2.0 - 4.0 : 223 values
[Exponent=2] 4.0 - 8.0 : 223 values
....

Or more precisely:

....
[Exponent=-3] 0.125 ≤ x < 0.25 : 223 values
[Exponent=-2] 0.25 ≤ x < 0.5 : 223 values
[Exponent=-1] 0.5 ≤ x < 1.0 : 223 values
[Exponent=0] 1.0 ≤ x < 2.0 : 223 values
[Exponent=1] 2.0 ≤ x < 4.0 : 223 values
[Exponent=2] 4.0 ≤ x < 8.0 : 223 values
....