3 ms·
Well, those are all error conditions and not a number. NaN's explicitly say they aren't, and +-Inf may or may not be infinity, all we know is that it is outsid
by beached_whale 6y ago
Well, those are all error conditions and not a number. NaN's explicitly say they aren't, and +-Inf may or may not be infinity, all we know is that it is outside the representable range of IEEE floating point.
- derefr 6y agoIMHO, code should check for floating-point overflow just like it checks for integer overflow. If your inputs are finite and your output is infinite, that's similar to your inputs being positive and your output being negative: you should check for it and emit an error instead. Then infinity (like negative numbers) can have an actual semantic meaning, rather than just being the detritus of an error condition.
- jjgreen 6y agoNaNs have an odd ontology, regardless of what they claim to be. For example, hypot(Inf, NaN) == Inf (C99), which suggests that NaN is "some number but we cannot know what it is".