round() to nearest .05 ?

tertius terti at mighty.co.za
Mon Nov 15 15:52:42 EST 2004


Hi,

I'm trying to round my float total to the nearest .05 cents.

12.01    should produce 12.00
  0.14    should produce 0.10
  2.28          "        2.25
703.81         "        703.80

"%.02f"%100.0099 produces 100.01 (which I know is right)
No combination of round and/or "%.02f" works for me.

What's the best way to get there? Should I write a function to manage my 
rounding or is there a simpler/better way?

TIA
T



More information about the Python-list mailing list