3 ms·
> Fwiw, floats do exactly this the only difference is that you've changed your base from 2 to 10 No, exact rationals aren't equivalent to decimal floating poin
by dragonwriter 7y ago
> Fwiw, floats do exactly this the only difference is that you've changed your base from 2 to 10
No, exact rationals aren't equivalent to decimal floating point, which while not as good as arbitrary precision rational or decimal representation is still better than binary floating point for decimal literals. In arbitrary precision decimal or rational representation, or even Raku's bounded denominator rationals, if p and q are decimal literals that can be exactly represented in the representation, then so are p + q and p - q. For the arbitrary precision versions, subject to available memory, so are p × q and p ÷ q. Fixed-size floating point (binary or decimal) provides none of those precision guarantees (whether for decimal or binary literals).