[newbie] decimal precision

Darrell news at dorb.com
Mon Sep 6 17:41:59 EDT 1999


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 e.g.
round(0.5) is 1.0 and round(-0.5) is -1.0).


--
--Darrell
Neil Conway <neilconway at home.com> wrote in message
news:37D4332A.EE85F4D3 at home.com...
> Hello all.
>
> I was wondering if anyone knows how to limit decimal precision in
> Python. Here is an example of where my problem occurs:
>
> >>> 3.0 / 7
> 0.428571428571
>
> Lets say I wanted to limit the value it returns to 3 decimal places, for
> example. How would that be done?
>
> Thanks in advance,
>
> Neil Conway






More information about the Python-list mailing list