Finding the mantissa from binary with floating point numbers?

23.8k Views Asked by At

Here is the example problem slide I am working with:

slide with task

I understand how to get the exponent, its just 2+128=130-127=3

I understand the first bit is the sign bit for positive or negative.

I just get lost with the mantissa. I know each mantissa has to have a 1 before the decimal, but I'm unsure where the .75 came from. 1100000000000000000000 isn't 75 in decimal I mean right?

How do I calculate the mantissa with floating point numbers in binary?

2

There are 2 best solutions below

1
On

Received answer from /u/empire539 on Reddit.

Yes, there is an implicitly "hidden" bit, so if your mantissa is 1100000000000000000000, then that corresponds to the base 2 number 1.11.

Now, if you want to compute the value of .11 part, you just do the same thing as you would do to convert a normal binary number to decimal: multiply each bit by a power of 2.

So, for example, if you wanted to convert the number 1010.1 to decimal, you would do: $1(2^3) + 0(2^2) + 1(2^1) + 0(2^0) + 1(2^{-1}) = 8 + 2 + 1/2 = 10.5$

0
On

The number after "." is calculated by $$\frac1{2^n}$$ instead of $$2^n$$ So $$1.11 = 2^0 + (1/2^1) + (1/2^2)$$ $$= 1 + 0.5 + 0.25$$ $$=1.75$$