Also: in javascript you can divide by zero
> 1/0
Infinity
But python throws a divide by zero error:
>>> 1/0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
Still you do have infinity and nan in python - because these are part of the floating point spec.
>>> float('inf') - float('inf')
nan
>>> float('inf') == float('inf')
True
>>> NAN=float('inf') - float('inf')
>>> NAN == NAN
False
However that's not mathematics, it's computers (these are even stranger...)
I have my own little programming language - PYX [1] - and i don't allow this madness (even if it is a violation of the floating point spec ;-)
pyx
> mathconst.Infinity - mathconst.Infinity
Error: results in 'not a number' - that's not allowed here
#(1) mathconst.Infinity - mathconst.Infinity
|....................^
> 1/0
Error: Can't divide by zero
#(1) 1/0
|..^
[1] PYX -
https://github.com/MoserMichael/jscriptparse - it's supposed to be an educational programming language, where I am trying to have detailed error messages, my side project.