Are all integers with exponent over 52 are even in 64 bit floating point

筅森魡賤 提交于 2019-12-11 06:15:12

问题


Am I correct to conclude that:

  • all integers with exponent over 52 in the 64 bit floating point will be even? For example, if exponent is 53, and the mantissa is 0000000000000000000000000000000000000000000000000001, then the number is 100000000000000000000000000000000000000000000000000010 - ends in 10. If the mantissa is 54 the number ends with 100.

  • the more we increase the exponent, the more integer numbers can not be represented - for the exponent of 54 - it's impossible to represent one number - 9007199254740993, with exponent of 55 - we can't represent 3 numbers (because we have two bits left out of mantissa which can have combinations of 01,10,11).


回答1:


all integers with exponent over 52 in the 64 bit floating point will be even?

Yes. F64 has 52 encoded mantissa bits, plus an implied one. We are talking about an 'unbiased' exponent, so your value is 2^exp*1.mant.

Imagine that to convert the F64 to an integer, the mantissa will be left-shifted by the unbiased exponent. Shifting by 52 will guarantee an integer that doesn't need rounding. 53 will guarantee an even number as zeroes are shifted in like you showed.

the more we increase the exponent, the more integer numbers can not be represented

Yes, but this goes much faster than you describe. Your example value is simply this first occurrence. In the range (2^53, 2^54) where only even numbers can be represented like you stated, only half of all integers exist in the F64, so in that range all 2^52 odd integers are unrepresented.



来源:https://stackoverflow.com/questions/39304010/are-all-integers-with-exponent-over-52-are-even-in-64-bit-floating-point

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