News for hackers. Stuff that matters.
Re:What I didn’t know about Ruby Numbers by ivanbakel on Thursday November 19, 2020 @09:38AM (#25149934)
That's too pedantic. Floats are not exact real numbers because they cannot represent most reals exactly.

There's no need to use a float operation to see this inexact behaviour - floats cannot even represent most reals that humans can write in a computer program. If you write `0.1` in your programming language of choice such that it gets treated as a float, the result is not, in any way, exactly 0.1.

Re:What I didn’t know about Ruby Numbers by voxic11 on Thursday November 19, 2020 @10:02AM (#25150196)
But the reals that they can represent are represented exactly. 0.5 + 0.5 = 1.
Re:What I didn’t know about Ruby Numbers by wwright on Thursday November 19, 2020 @12:55PM (#25152175)
I didn’t claim they are _any_ exact real number or that they are _exactly_ the same as the decimal literal they are conveyer from. I said they are exact, which they are. (And further, that they are binary and not decimal.)
Re:What I didn’t know about Ruby Numbers by recursive on Thursday November 19, 2020 @10:11AM (#25150282)
If that's your criteria, then neither are BigDecimals exact real numbers.
Re:What I didn’t know about Ruby Numbers by ivanbakel on Thursday November 19, 2020 @10:50AM (#25150686)
That's certainly true. The rationals (of which BigDecimal cannot represent the whole space) are a 0-measure part of the reals. I would not claim that BigDecimal is an exact representation, which is a fact that should be clear to anyone that tries to calculate 2 * PI in arbitrary-precision finite decimals. Even not considering irrational numbers, BigDecimal cannot handle 1/3 + 1/3 + 1/3 = 1 correctly.

It might be fair to claim that floats are more inexact - certainly moreso than Rational, but probably moreso than BigDecimal for the numbers that programmers tend to care about.