4
votes

Consider a 32 bit floating point number (IEEE 754) having 0-22 for mantissa(23 bits) , 23-30 for exponent(8 bits) , 31 for sign(1bit)
I want to find out the smallest positive number that can be stored.
I have been told answer is 1.18*10-38 which is approx 2-126
My analysis is as follows
if we put all zeroes in mantissa and put all ones in exponent then the decimal equivalent would be
1.0 x 2-128 = 2.93 x 10-39

Where am I going wrong ?
Thanks

2
As Wikipedia explains, "Exponents range from −126 to +127 because exponents of −127 (all 0s) and +128 (all 1s) are reserved for special numbers."Raymond Chen
"I have been told answer is 1.18*10-38" <- That's not correct: that value is the smallest positive normal number that's representable. The smallest positive number that's representable is 2^149, or approximately 1.4*10^-45.Mark Dickinson

2 Answers

2
votes

If you put all ones in exponent you will get NaN if mantissa is non-zero or infinite if mantissa is 0. Wikipedia IEEE 754. Also your minimal value is inside Denormal numbers space when exponent is binary equal to 0.

0
votes

Although 8 bits exponent means -127 to +128 but two case is reserved for special values (See here), so the most negative exponent is -126.

BTW, it's impossible to store -128 in 8 bits in Two's Complement system which is the base system used in exponent of IEEE 754.