I'm working on a task for A-Level Comp Sci and one question involves normalising the number 110.110 in floating point representation with a 6 bit mantissa and a 4 bit exponent. What is the correct way to do this?
I can't move the decimal point to the beginning of the mantissa (0.110110) as that would cause it to exceed 6 bits but I also can't move the decimal point to the first 1 (1.10110) because then it would act as a negative sign bit. Do I just leave it as is with no exponent or is there something I'm missing? Many thanks.
In IEEE-754 normalized numbers mantissa always lies in range 1.0..2.0
, in binary 1.0000000 ... 1.1111111
. Bit before point is always set, so it is omitted, and we store only part of mantissa after point.
In your case 110.110 = 100 * 1.10110
, so mantissa is 10110
(or 101100
if 6 bits needed)
Exponent 100
perhaps is stored as 100 + 111 = 1011
(by analogy with single precision exponent stored as e+127
).
Sign bit in IEEE-754 float values is separate leftmost bit. Don't sure about your format
So I suppose the next binary code:
0 1011 101100
s eeee mmmmmm