Live data from Hacker News

1.5 is the midpoint between 0 and infinity in Ruby

blog.peterzhu.ca

121–125 of 125 posts

Re: 1.5 is the midpoint between 0 and infinity in Ruby

#121
post #51

Earlier quoted context omitted.

That's not right. 1 is different to half the sum of 0 and infinity. Another way to look at it is that infinity minus one is larger than one minus zero (which can be easily proven using the basic definitions used to define the surreals). Moreover, what is at the right side of {0|} is not infinity, but the empty set.

> Moreover, what is at the right side of {0|} is not infinity, but the empty set. But { 0 | ω } = 1, right?

Correct. As is { 0 | n } for any n > 1.

Re: 1.5 is the midpoint between 0 and infinity in Ruby

#122
post #101

Like every blog post or article that talks about something weird related to IEEE floats, this absolutely needs to find a way to link to "What Every Computer Scientist Should Know About Floating-Point Arithmetic", over on https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.h... , because that's mandatory reading if you're programming.

Shorter and at a level the simple masses of programmers will likely work at - https://docs.python.org/3/tutorial/floatingpoint.html#tut-fp...

Another short introduction to floating point number with pictures giving a better intuition of their distribution among real numbers:

https://blogs.mathworks.com/cleve/2014/07/07/floating-point-...

Re: 1.5 is the midpoint between 0 and infinity in Ruby

#123

Earlier quoted context omitted.

Infinitesimals tautologically exist in any finite representation of numbers. For floats, it's the smallest representable positive number. For integers of any type, it's 1. As for how common they are, we learn about them in any introductory calculus course when defining derivatives. You come across the idea whenever discussing limits, if somewhat obliquely. If I learned about it in high school math, and again in "real…

I've never heard of that, and your definition of 1 as infinitesimal is incompatible withbits properties (infinitesimal + infinitesimal + infinitesimal is greater than a non-infinitesimal 2?!) and I don't see a mention on Wikipedia, and it goes against the plain read it of "in-finite-simal". Also, you seem to be conflating "common" with "standard". "standard" is a mathematical term. Infinitesimal are handwavy in stand…

I guess I'm using the wrong term, then. I often find it useful to have a concept of "smallest representable positive number," specifically for handling edge cases such as the one I gave up-thread. I see how that doesn't map to infinitesimal as defined in the shared link.

There are other instances where I've had a need for such a smallest positive number, where logic is simplified as opposed to checking for 0 in a special way. Whether there's an agreed upon term for that, I know where I've found value in programming tasks.

When I need such a thing, it is almost invariably in comparisons, so I am not doing arithmetic with multiple instances of that smallest representable positive number.

Re: 1.5 is the midpoint between 0 and infinity in Ruby

#124

Earlier quoted context omitted.

When does this problem crop up when only dealing with pure ints?

Doing integer/rational arithmetic gives you a choice: either never do any rounding and require exponentially growing precision that makes even the simplest algorithms impractically expensive (not to mention giving up entirely on the many common computations which cannot be represented whatsoever in an exact rational arithmetic system), or allow rounding/approximation of some kind and end up with roughly the same prob…

While division is a problem, you could symbolically represent numbers such as 1/3 by storing the numerator and denominator as a fraction of 2 values.

Re: 1.5 is the midpoint between 0 and infinity in Ruby

#125
post #101

Earlier quoted context omitted.

Shorter and at a level the simple masses of programmers will likely work at - https://docs.python.org/3/tutorial/floatingpoint.html#tut-fp...

Having the actual explanation of why floats work the way they do, by explaining how the various kinds of numbers map to the various IEEE defined bit patterns, is crucial in understanding , rather than just having read some text. This python article skips over that entirely, making it yet another tutorial about the fact "that" floats are approximations instead of "why" floats are approximations. Spend the time up from…

When would knowing that they're an approximation ever be inadequate compared to knowing why they're an approximation in the real world for the simple masses? 99.99% of cases the decision goes "floats are fast and memory efficient, but I need full decimal precision, so I'll use the library"
Post reply on HN