[Solved] C++ float does not change when operand is smaller than 129 [closed]


We can understand what’s going on by looking at the anatomy of a 32-bit float. The value 3.0E9 in IEEE754 format is 0x4F32D05E, with exponent value 31 (you can use this online calculator to find the value).

Now we have 23 sub-unity binary digits left for the mantissa. That means that the smallest increment, i.e. the difference between to adjacent values of the mantissa, is a number with binary scale 31 − 23 = 8. Since 128 is 27, we see that it is just small enough to fall off the end of the mantissa, while 129 is large enough to be visible.

0

solved C++ float does not change when operand is smaller than 129 [closed]