Mike Meyer wrote:
Well, you want to be able to add floats to rationals. The results
shouldn't be rational, for much the same reason as you don't want to
convert floats to rationals directly. I figure the only choice that
leaves is that the result be a float. That and float(rational) should
be the only times that a rational gets turned into a float.

Are you suggestiong that float(rational) should be a string, with the
number of degrees of precesion set by something like the Context type
in Decimal?

Actually, I was misremembering how Decimal worked - it follows the rule you suggest:

float() + Decimal() fails with a TypeError
float() + float(Decimal()) works fine

And I believe Decimal's __float__ operation is a 'best effort' kind of thing, so I have no problem with Rationals working the same way.

Cheers,
Nick.

--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
            http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to