[Tutor] Rounding to n significant digits? (original) (raw)

Dick Moores rdm at rcblue.com
Fri Jul 2 00:52:48 EDT 2004


Dragonfirebane at aol.com wrote at 20:58 7/1/2004:

Look at the Python Docs . . . there exists round(number[, ndigits]) -> floating point number.

From the Docs:

================================ round( x[, n])

Return the floating point value x rounded to n digits after the decimal point. If n is omitted, it defaults to zero. The result is a floating point number. Values are rounded to the closest multiple of 10 to the power minus n; if two multiples are equally close, rounding is done away from 0 (so. for example, round(0.5) is 1.0 and round(-0.5) is -1.0).

So that won't do it. "rounded to n digits AFTER the decimal point".

But thanks,

Dick



More information about the Tutor mailing list