Max value - Mantissa calculation clarification?

1.9k Views Asked by At

I've been reading this article about floating point representation

floating point representation is :

enter image description here

Where mantissa is :

enter image description here

All understood.

But they also say :

enter image description here

How did they get to 2^(-23) ?

in the mantissa there are 23 bits which referes to 1.xxxxxxxxxxxxxxxxxxxxxxx

(23 x's)

so what is the max value for 23 bits ?

it's 2^(23)-1

Since x's it's location is on the right side so 2^(-22) and we need to add the 1.

So it should be 2^0 + 2^(-23)-1

How did they get to 2^(-23) ?

edit :

found the answer.

let's look at 3 bit mantissa for example :

1.111 will be the max

so it will be 1111.0 *2^(-3)

what's the value in the left side ? it's (2^4)-1

so let's do :

(2^4 - 1 )* 2^(-3) ==> which is 2 - 2^(-3)

1

There are 1 best solutions below

16
On BEST ANSWER

The largest mantissa consists of 23 bits 1: $$11111111111111111111111 = 2^{23}-1.$$ With the implied bit convention this gives for the real maximum Mantissa $M_m$ $$M_m=1.11111111111111111111111 = 1+(2^{23}-1)2^{-23} = 1+1 -2^{-23} = 2-2^{-23}$$ And therefore the largest number is $$M_m \times 2^{254-127}= (2-2^{-23})\times 2^{127} = 2^{128}-2^{104}\\ =340282346638528859811704183484516925440 \approx 3.40282\times 10^{38}$$