|
|
|
|
|
by lisael
2873 days ago
|
|
Meanwhile, in Python... In [1]: 255 + 1 is 256
Out[1]: True
In [2]: 256 + 1 is 257
Out[2]: False
Every language has its inconsistencies, when it comes to math, because they run on real-world computers. All these are "slow" interpreted languages that allow runtime failures and don't use plain machine integers. Just a different trade-off.Anyway, the Inf/NaN trick is not better than the 0 trick in my opinion, because all subsequent operations result happily in NaN. I've never seen in any NaN language a program that checks for NaN the result of each and every division. with a NaN-kind of language, it would be: a = b/c
if a == NaN:
print "oops"
with a 0-trick language: a = b/c
if a == 0 and c == 0:
print "oops"
not THAT different, IMO :) |
|