Re:1/0 = 0
by PopeDotNinja on Friday August 10, 2018 @05:15PM
(#17736801)
Meanwhile, in Python v3.7.0...
Meanwhile, in Elixir v1.7.1...
Meanwhile, in Ruby v2.5.1...
Meanwhile, in PHP v7.0.8...
Meanwhile, in Node v10.7.0...
[ Parent
| on HN ]
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 :)
Re:1/0 = 0
by PopeDotNinja on Saturday August 11, 2018 @12:22AM
(#17738331)
When I make a language, there will be a OuchMyHeadHurtsCommaSpaceGotSomeAspirinQuestionMarkError.