<p dir="ltr">On May 31, 2015 7:26 PM, "u8y7541 The Awesome Person" <<a href="mailto:surya.subbarao1@gmail.com">surya.subbarao1@gmail.com</a>> wrote:<br>
><br>
> Dear Python Developers:<br>
><br>
> I will be presenting a modification to the float class, which will improve its speed and accuracy (reduce floating point errors). This is applicable because Python uses a numerator and denominator rather than a sign and mantissa to represent floats.</p>
<p dir="ltr">Python's floats are in fact ieee754 floats, using sign/mantissa/exponent, as provided by all popular CPU floating point hardware. This is why you're getting the results you see -- 1/3 cannot be exactly represented as a float, so it gets rounded to the closest representable float, and then as_integer_ratio shows you an exact representation of this rounded value. It sounds like you're instead looking for an exact fraction representation, which in python is available in the standard "fractions" module:</p>
<p dir="ltr"><a href="https://docs.python.org/3.5/library/fractions.html">https://docs.python.org/3.5/library/fractions.html</a></p>
<p dir="ltr">-n</p>