3 ms·
No, it comes from the fact that floating point is binary and has limited precision. Think of it in terms of scientific notation. Here's an example in decimal. I
by AdamH12113 3y ago
No, it comes from the fact that floating point is binary and has limited precision. Think of it in terms of scientific notation. Here's an example in decimal. If we limit ourselves to four significant digits, then a number like:
3.101 * 10^3
is odd -- it's equivalent to 3101 (three thousand one hundred one). It's followed by 3.102*10^3 (3102), which is even, and 3.103*10^3 (3103), which is odd. But a number like:
3.101 * 10^5
which is equivalent to 310100, is even. It's followed by 3.102*10^5 (310200), which is also even, and 3.103*10^5 (310300), which is again even. If you have four significant digits and an exponent larger than 3, then you the value in the ones place will always be zero. Thus, the number is always a multiple of 10, and therefore even.
Floating point is the same, except it's binary. In a 32-bit float, you have 23 bits of mantissa after the decimal point. If the exponent is larger than 2^23, the ones place is always zero, so the number is guaranteed to be a multiple of 2, and therefore even.