3 ms·
Is the “thus” for ease of implementation? I.e., so that all floating-point numbers comparing greater than some threshold can be considered even without having t
by layer8 4y ago
Is the “thus” for ease of implementation? I.e., so that all floating-point numbers comparing greater than some threshold can be considered even without having to check for infinity?
- pxx 4y agoIt's not that they are considered even, they just are. There's no way to encode a large odd even-radix floating point number. You have some (small, compared to the range that the exponent can encode) bits of significand and once you exhaust those all numbers are even (or divisible by ten in the rare decimal case).
- layer8 4y agoIEC 60559 could have defined pow(-1, ∞) as -1 if they’d wanted to. Hence my question what the “thus” is about.
- AdamH12113 4y agoNo, 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.