PEP proposal for round(x,n) enhancement

Markus Schaber markus at schabi.de
Mon Sep 17 11:16:14 EDT 2001


Hi,

As you requested it, have my vastest criticism :-)

Christopher Smith <csmith at blakeschool.org> schrub:

> If n=0 (the default value for round2) then the magnitude of the
> number will be returned (e.g. round2(12) returns 10.0).

Maybe the doc should notify that all this is done to the base 10.
 
> If n<0 then x will be rounded to the nearest multiple of n which, by
> default, will be rounded to 1 digit (e.g. round2(1.23,-.28) will round
> 1.23 to the nearest multiple of 0.3.

I don't see the sense of rounding n by default. In my eyes this is 
unexpected behaviour, and it is unclear how to achieve a completely 
unmodified n (have to guess a high value for sigs4n?). I'd make 
sigs4n=None by default, and not modify n in this case.

What happens when I use a negative value in sigs4n? Maybe it should be 
documented when the result is useful, otherwise it might make sense to 
forbid it and throw an exception - or document it as undefined.

I still don't feel good with the implicit overloading of two meanings 
using the sign of n (would rather see two differend functions for this) 
- the same applied to your first idea of modifying round basing of 
int/float.

markus
-- 
"The strength of the Constitution lies entirely in the determination of 
each citizen to defend it. Only if every single citizen feels duty 
bound to do his share in this defense are the constitutional rights 
secure." -- Albert Einstein



More information about the Python-list mailing list