4 ms·
You're absolutely right. Not only that, but it's impossible to distinguish a bad result like 1/0 vs a good result like 0/1. Even Javascript is better with "NaN
by madrox 8y ago
You're absolutely right. Not only that, but it's impossible to distinguish a bad result like 1/0 vs a good result like 0/1.
Even Javascript is better with "NaN"
- jwilk 8y agoTo clarify, in Javascript 1/0 is Infinity, not NaN.
- eggnet 8y agoYou are correct. But it really should be NaN, since 1/ε is positive infinity, whereas 1/-ε is negative infinity. Oh well :)
- Jach 8y agoJS just assumes the limit direction for you, so 1/0 is Infinity, but -1/0 is -Infinity. 0/0 at least is correctly NaN. (Edit: And I just verified against my memory, Matlab (or at least Octave) does the same thing. While Matlab might get characterized as being for the ivory tower, at least it's had a long history of being used for practical math applications within the tower. Edit2: And anyway this is the defined behavior for IEEE floats. Men of industry use industrial standards. :))
- lightgreen 8y agoMoreover, 1/-0 is -Infinity. IEEE float has two zeros, positive and negative.
- mehrdadn 8y agoNope, I'd disagree. Zero isn't an approximation of some epsilon, it's really just zero. It makes sense for the output sign to match the input sign.
- gowld 8y agoWhat is the sign of 0? It's 0.
- lightgreen 8y agoe is nearly 0, -e is nearly -0. So 1/0 is infinity, and 1/-0 is -infinity.