[Tutor] Rounding to n significant digits?
Dick Moores
rdm at rcblue.com
Thu Jul 1 23:03:11 EDT 2004
Is there something (a function?) in Python 2.3.4 that will round a result
to n significant digits, or do I need to roll my own? I don't see one in
the math module.
I mean something like rounding(float, n) that would do this:
float = 123.456789, n = 4, returns 123.5
float = .000000123456789, n = 2, returns .00000012
float = 123456789, n = 5, returns 123460000
Thanks,
Dick Moores
More information about the Tutor
mailing list