max float represented in IEEE 754

旧巷老猫 提交于 2019-12-30 08:59:32

问题


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




回答2:


Being the "m" the mantisa and the "e" the exponent, the answer is:

In your case, if the number of bits on IEEE 754 are:

  • 16 Bits you have 1 for the sign, 6 for the exponent and 11 for the mantisa. The largest number represented is 4,293,918,720.
  • 32 Bits you have 1 for the sign, 8 for the exponent and 23 for the mantisa. The largest number represented is 3.402823466E38
  • 64 Bits you have 1 for the sign, 11 for the exponent and 52 for the mantisa. The largest number represented is 2^1024 - 2^971


来源:https://stackoverflow.com/questions/10233444/max-float-represented-in-ieee-754

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!