assemblyfloating-pointbinaryieeemantissa

Calculating value from 5-bit float representation


I have worked on this quite a bit, and think I'm missing something about the "frac" part. In this 5-bit float, the sign bit is the most significant, the next two bits are the exponent and the exponent bias is 1. The last two bits are the significand(Mantissa).

So I have a bunch of values, but I'm just trying to understand the method better. The first one is:

0 00 01

I know the equation is

V = (-1)^s * m * 2^E

Sign is zero, and since the number is denormalized, E = 1-bias = 0 (is that right?)

So, I have:

V = 1 * m * 1

The issue I'm having is with the mantissa value. I thought for denormalized numbers, it equals 0.frac, and the frac here equals 1 right?

So does m = .1?

I found a bunch of stuff online that makes it look like the frac is the value over the number of bits?

So maybe m = 1/5?

Finally, I'm told my answer should be expressed as x/4. So is m supposed to be 1/4? If so, why?

Thanks for any help or teaching anyone can offer!


Solution

    1. The exponent is usually computed as the value of the "exponent" field (let's call it "ex") minus the bias, which allows us to only keep non-negative numbers in the exponent field. However, there may be one exception, see below.

    2. The significand is usually stored without the leading 1, which is implicit. This doesn't have to be the case (e.g. long double keeps the leading one explicitly), but it makes sense to conserve the space and also means you have unique representations of values.

    3. If the significand doesn't store the leading 1, then there's a special case for denormalized numbers, i.e. when the exponent field is all zero. In that case, there is no implicit 1, and to make the transition monotonic, the smallest possible exponent is, as you rightly say, 1 − ex.

    4. The significand is this 0.01b, i.e. 1/4. Since the number is denormal, there is no leading 1, and so the actual mantissa is 1/4. The exponent is zero (namely 1 − 1), and so the total value of the number is 1/4.