3 ms·
Good point. To reduce this problem you can (and should?) factorise and cancel out common primes. Just keeping to a pair of 64 bit integers will give you a prett
by SagelyGuru 11y ago
Good point. To reduce this problem you can (and should?) factorise and cancel out common primes. Just keeping to a pair of 64 bit integers will give you a pretty good accuracy. You can perform all arithmetic directly on the rationals and represent reals by the nearest rational approximation (after all, a float is an approximation too in those cases, just a poorer one).
Stern-Brocot trees are a good systematic way of finding the best rational approximations and also for doing interval rational arithmetic.