3 ms·
Infinity is a special type of NaN where the fraction component is all 0.
by chipsa 5y ago
Infinity is a special type of NaN where the fraction component is all 0.
- Dylan16807 5y agoI'm pretty sure that's just a storage optimization and not one being a subset of the other.
- quietbritishjim 5y agoFor example: nan==nan is false but inf==inf is true
- klodolph 5y agoIt's not actually a storage optimization. A number is either NaN (mantissa != 0) or Inf (mantissa == 0).
- quietbritishjim 5y agoI think they meant that having the same exponent, even though they are logically different numbers, is a storage optimisation.
- Dylan16807 5y agoWhat's your definition of storage optimization, where zero and nonzero mantissas meaning completely different things doesn't qualify?
- klodolph 5y agoZero and nonzero mantissas always mean different things, no matter what the exponent is. I guess I am not sure how this could be described as an optimization... an optimization relative to what? Some hypothetical floating-point format which has extra bits?
- Dylan16807 5y ago> Zero and nonzero mantissas always mean different things, no matter what the exponent is. They don't normally mean different types of value. 4.0000000 and 4.0000001 are just different adjacent numbers. > I guess I am not sure how this could be described as an optimization... an optimization relative to what? Some hypothetical floating-point format which has extra bits? Using the exponent to distinguish, like the format uses for normal/subnormal/nonfinite. Or using extra bits, sure. They took a bit pattern that would have been a NaN if not for Infinity, and used it to store Infinity.
- stephencanon 5y agoInfinity is not a special type of NaN. Infinity and NaN are encoded with the same exponent, but they are distinct numerical data.
- klodolph 5y agoYou might think of floating-point numbers coming in five varieties: - normal (exponent not minimum or maximum) - zero (minimum exponent, mantissa == 0) - subnormal (minimum exponent, mantissa != 0) - infinity (maximum exponent, mantissa == 0) - nan (maxmimum exponent, mantissa != 0) NaN is only the last category, strictly. Finite is everything except infinity and nan. Subnormal and zero are collectively denormal. The distinction between "subnormal" and "denormal" is a bit esoteric.