2 ms·
It's not so much the need for arbitrary storage, the problem is that even easy rationals can't be expressed in the IEEE floats Take realistic::Rational::fracti
by tialaramex 1y ago
It's not so much the need for arbitrary storage, the problem is that even easy rationals can't be expressed in the IEEE floats
Take realistic::Rational::fraction(1, 3) ie one third. Floats can't represent that, but we don't need a whole lot of space for it, we're just storing the numerator and denominator.
If we say we actually want f64, the 8 byte IEEE float, we get only a weak approximation, 6004799503160661/18014398509481984 because 3 doesn't go neatly into any power of 2.
Edited: An earlier version of this comment provided the 32-bit fraction 11184811/33554432 instead of the 64-bit one.