On Sun, Sep 25, 2011 at 3:31 PM, Steven D'Aprano
<steve+comp.lang.pyt...@pearwood.info> wrote:
>>>> 2.1 == F(21, 10)
> False
>

Ahh, but that may just mean that Fraction doesn't implement an == that
compares with floats.

>>> 2.1==float(F(21,10))
True

This may be because one oughtn't to use == with floats anyway.

>>> F(2.1)==F(21,10)
False
>>> F(2.1)
Fraction(4728779608739021, 2251799813685248)

That denominator is a power of 2 (2**51 as it happens), which is
unsurprising for something created from an IEEE floating point value.
Rounding F(21,10) off to fit into float produces this same value.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to