round() function strange behaviour
brobbins333 at shaw.ca
brobbins333 at shaw.ca
Sat Mar 9 21:19:25 EST 2002
OK, that's pretty much what I had in mind too.
Thanks for your help.
Bruce
On Sun, 10 Mar 2002 01:29:18 GMT, Erik de Castro Lopo
<nospam at mega-nerd.com> wrote:
>
> erikd at coltrane > python
> Python 2.1.2 (#1, Jan 18 2002, 18:05:45)
> [GCC 2.95.4 (Debian prerelease)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> x = 56.78923
> >>> x_as_string = "%.2f" % x
> >>> print x_as_string
> 56.79
>
>Just what you want. Remember however that if you want to operate on the
>number using standard arithmetic you need to work on x rather than
>x_as_string.
>
>Erik
>--
>+-----------------------------------------------------------+
> Erik de Castro Lopo nospam at mega-nerd.com (Yes it's valid)
>+-----------------------------------------------------------+
>"The whole principle is wrong; it's like demanding that grown men live on
>skim milk because the baby can't eat steak."
>- author Robert A. Heinlein on censorship.
More information about the Python-list
mailing list