A rational proposal
Nick Coghlan
ncoghlan at iinet.net.au
Wed Dec 22 08:25:06 EST 2004
More information about the Python-list mailing list
Wed Dec 22 08:25:06 EST 2004
- Previous message (by thread): A rational proposal
- Next message (by thread): A rational proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 | ncoghlan at email.com | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.skystorm.net
- Previous message (by thread): A rational proposal
- Next message (by thread): A rational proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list