[Python-ideas] Python Float Update

Cameron Simpson cs at zip.com.au
Mon Jun 1 06:37:23 CEST 2015


On 31May2015 20:27, David Mertz <mertz at gnosis.cx> wrote:
>On Sun, May 31, 2015 at 8:14 PM, <random832 at fastmail.us> wrote:
>
>> 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.
>>
>
>What is the computational complexity of a hypothetical
>float.as_simplest_integer_ratio() method?  How hard that is to find is not
>obvious to me (probably it should be, but I'm not sure).

Probably the same as Euler's greatest common factor method. About log(n) I 
think. Take as_integer_ratio, find greatest common factor, divide both by that.

Cheers,
Cameron Simpson <cs at zip.com.au>

In the desert, you can remember your name,
'cause there ain't no one for to give you no pain.      - America


More information about the Python-ideas mailing list