[Python-ideas] Python Float Update
Stefan Behnel
stefan_ml at behnel.de
Mon Jun 1 09:10:24 CEST 2015
random832 at fastmail.us schrieb am 01.06.2015 um
05:14:
> On Sun, May 31, 2015, at 22:25, u8y7541 The Awesome Person wrote:
>> First, I propose that a float's integer ratio should be accurate. For
>> example, (1 / 3).as_integer_ratio() should return (1, 3). Instead, it
>> returns(6004799503160661, 18014398509481984).
>
> Even though he's mistaken about the core premise, I do think there's a
> kernel of a good idea here - it would be nice to have a method (maybe
> as_integer_ratio, maybe with some parameter added, maybe a different
> method) to return with the smallest denominator that would result in
> exactly the original float if divided out, rather than merely the
> smallest power of two.
The fractions module seems the obvious place to put this. Consider opening
a feature request. Target version would be Python 3.6.
Stefan
More information about the Python-ideas
mailing list