float, '%.2f' help... please!

chibaA at TinterlogD.Tcom chibaA at TinterlogD.Tcom
Tue Jun 27 22:44:37 EDT 2000


Hi,

I'm just kinda stuck for answers...  I need to display a price -
rounded up to the proper cent.  I was using this line:

print '%.2f' % (price+0.005)

Thinking that it would just chop off the float at the second decimal.
But when I had a value of 0.00 for price, it seemed to round up.  To
be sure, I wanted to find a method of printing that would just chop
off any decimals after 2 - and NOT round up or down.  Is there such a
method?

Thanks!



More information about the Python-list mailing list