Hacker News new | past | comments | ask | show | jobs | submit login

> Why don't we just get our computer languages to understand what "2, 3, ..., 12" means?

Some languages already do: for example, in Ruby you can use (-5..-1) to get [-5, -4, -3, -2, -1]. It's lazy evaluation, so you can even do stuff like:

    Infinity = 1.0/0.0
    (1..Infinity).step(2).take(5) #=> [0, 2, 4, 6, 8]



Just FYI you can get infinity without evaluating an expression: it’s defined on Float, Float::INFINITY


> Ruby

And before, Perl:

https://perldoc.perl.org/perlop.html#Range-Operators

I like ranges in Perl.



I remember seeing a rather convincing argument that 1.0/0.0 should not be infinity, but zero.


This is how Pony handles division. There's a good summary of possible motivations here: https://www.hillelwayne.com/post/divide-by-zero/


I pasted the wrong link above, but my mobile app isn't letting me edit it. This is the link that describes their reasoning: https://tutorial.ponylang.io/gotchas/divide-by-zero.html


Thank you! The mention of Pony gave me just enough ammunition to search for the article I remembered seeing. https://news.ycombinator.com/item?id=17736046

P.S. the link you provided is exactly the one.


You mean mathematically, or specifically for programming?

For programming, I imagine it's better for it to be infinity than 0 since having 0 in the denominator implies that it's changing (who would write a constant 0 in a denominator?), and so as the denominator is approaching 0, the fraction is getting closer and closer to pos/neg infinity, not 0. Making it evaluate to zero would imply a change of direction for whatever the fraction represents.

So, if it's a position, as the position goes 1000/1000, 1000/500, 1000/100, 1000/1, etc. it's getting closer to infinity. Having it suddenly go to 0 would break the pattern of movement.

Mathematically, there is no x that satisfies x = 1/0 -> x * 0 = 1, since anything multipled by 0 is 0, so it's undefined.


Yes, there's a discontinuity between the positive and negative numbers, that was part of the argument. Another part was that certain mathematical formulas get simpler when x/0 = 0.


Do you remember seeing or do you remember?


It was something on the internet. I wish I could come up with the proper search terms to find it again.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: