[Python-ideas] Python Float Update

Cameron Simpson cs at zip.com.au
Mon Jun 1 07:27:45 CEST 2015


On 01Jun2015 01:11, random832 at fastmail.us <random832 at fastmail.us> wrote:
>On Mon, Jun 1, 2015, at 00:37, Cameron Simpson wrote:
>> 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.
>
>Er, no, because (6004799503160661, 18014398509481984) are already
>mutually prime, and we want (1, 3). This is a different problem from
>finding a reduced fraction.

Ah, you want the simplest fraction that _also_ gives the same float 
representation?

>There are algorithms, I know, for
>constraining the denominator to a specific range
>(Fraction.limit_denominator does this), but that's not *quite* the same
>as finding the lowest one that will still convert exactly to the
>original float

Hmm.

Thanks for this clarification.

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

The Design View editor of Visual InterDev 6.0 is currently incompatible
with Compatibility Mode, and may not function correctly.
- George Politis <george at research.canon.com.au>, 22apr1999,
  quoting http://msdn.microsoft.com/vstudio/technical/ie5.asp


More information about the Python-ideas mailing list