A rational proposal
Dave Benjamin
ramen at lackingtalent.com
Sun Dec 19 21:16:01 EST 2004
Hi Mike - Thanks for taking the time to put this together.
In article <864qik472n.fsf at guru.mired.org>, Mike Meyer wrote:
> - max(*args): return the largest of a list of numbers and self.
> - min(*args): return the smallest of a list of numbers and self.
I would strongly prefer either adapting the already built-in min/max
functions to support this type or creating functions in a module rather than
using the method approach. My reason is the assymetry; I would much prefer:
rational.max(rat1, rat2, rat3)
over:
rat1.max(rat2, rat3)
for the simple reason that the latter looks unbalanced and empbasizes "rat1"
when there is really no reason to do so.
> Rationals will mix with all other numeric types. When combined with an
> integer type, that integer will be converted to a rational before the
> operation. When combined with a floating type - either complex or
> float - the rational will be converted to a floating approximation
> before the operation, and a float or complex will be returned. The
> reason for this is that floating point numbers - including complex -
> are already imprecise. To convert them to rational would give an
> incorrect impression that the results of the operation are
> precise. Decimals will be converted to rationals before the
> operation. [Open question: is this the right thing to do?]
Sounds right to me.
Cheers,
Dave
--
.:[ dave benjamin: ramen/[sp00] -:- spoomusic.com -:- ramenfest.com ]:.
"talking about music is like dancing about architecture."
More information about the Python-list
mailing list