max float represented in IEEE 754

2019-02-17 18:56发布

问题:

I am wondering if the max float represented in IEEE 754 is:

(1.11111111111111111111111)_b*2^[(11111111)_b-127]

Here _b means binary representation. But that value is 3.403201383*10^38, which is different from 3.402823669*10^38, which is (1.0)_b*2^[(11111111)_b-127] and given by for example c++ <limits>. Isn't (1.11111111111111111111111)_b*2^[(11111111)_b-127] representable and larger in the framework?

Does anybody know why?

Thank you.

回答1:

The exponent 11111111b is reserved for infinities and NaNs, so your number cannot be represented.

The greatest value that can be represented in single precision, approximately 3.4028235×1038, is actually 1.11111111111111111111111b×211111110b-127.

See also http://en.wikipedia.org/wiki/Single-precision_floating-point_format