PEP proposal for round(x,n) enhancement

Chris Barker chrishbarker at
Thu Sep 13 01:11:36 CEST 2001

Markus Schaber wrote:

> And this is what I meant - the float doesn't store how many digits are
> significant, so when you round to n digits, you often get an
> approximation to the rounded number, and this way don't have any
> information about the accuracy afterwards.

OK, I get it now, but this doesn't make the proposal any more useless
than the current round. 
>>> round(0.2,3)

Just because Python doesn't store any information about the accuaracy,
doesn't mean that the programmmer doesn't know what was done. If you
take this now stored number and display the first <17 digits, it will
display what is wanted, and if you do calculations with it, it will do
what is wanted as well (as well as FP ever can).

> My proposal only has to do with enhancing the
> > syntax used by the round() function.
> And enhancing the semantics :-)

True, which is why I'd be just as happy to see it in a separate

Note: the current round() will accept decimal input, even if it doesn't
do anything with it, so adding this functionality does hav ethe
potential to break someones code, somewhere:

>>> round(1.2345,2.3)
>>> round(1.2345,0.3)


Christopher Barker,
ChrisHBarker at                 ---           ---           --- ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------

More information about the Python-list mailing list