<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 3, 2015 at 9:01 PM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">But there was a big issue that we didn't anticipate. During the course of a simple program it was quite common for calculations to slow down dramatically, because numbers with ever-larger numerators and denominators were being computed (and rational arithmetic quickly slows down as those get bigger).</blockquote></div><br>The problem of unlimited growth can be solved by rounding, but the result is in many ways worse that floating point</div><div class="gmail_extra">numbers.  One obvious problem is that unlike binary floating point where all bit patterns represent different numbers,</div><div class="gmail_extra">only about 60% of fractions with limited numerators and denominators represent unique values.  The rest are</div><div class="gmail_extra">reducible by dividing the numerator and denominator by the GCD.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Furthermore, the fractions with limited numerators are distributed very unevenly on the number line.  This problem</div><div class="gmail_extra">is present in binary floats as well: floats between 1 and 2 are twice as dense as floats between 2 and 4, but with</div><div class="gmail_extra">fractions it is much worse.  Since a/b - c/d = (ad-bc)/(bd), a fraction nearest to a/b is at a distance of 1/(bd) from it.</div><div class="gmail_extra">So if the denominators are limited by D (|b| < D and |d| < D), for small b's the nearest fraction to a/b is at distance</div><div class="gmail_extra">~ 1/D, but if b ~ D, it is at a distance of 1/D^2.  For example, if we limit denominators to 10 decimal digits, the gaps</div><div class="gmail_extra">between fractions can vary from ~ 10^(-10) to ~ 10^(-20) even if the fractions are of similar magnitude - say between</div><div class="gmail_extra">1 and 2.</div><div class="gmail_extra"><br></div><div class="gmail_extra">These two problems rule out the use of fractions as a general purpose number.  </div><div class="gmail_extra"> </div><div class="gmail_extra"><br></div></div>