[Tutor] number formatting
Brad Chandler
mbc2@netdoor.com
Fri, 12 Jan 2001 09:36:45 -0600
Thanks for the answers on the rounding issue. I suspected it had something
to do with floating point numbers but I just wasn't sure what was happening
and why. I was trying to match some numbers produced by another program
which apparently handles numbers differently. I was only off by about $1.50
over about $1.3 billion, so I guess that's close enough.
Right now I'm trying to figure out how to format numbers as currency. For
example, I want to turn this: 1314403624.57
into this: $1,314,403,624.57
Now I can easily add a $ to the front of the string, but how do I get those
commas in there? I'm currently using '%.2f' % myfloatingpointnumber to
format it to two decimal places, is there another option which adds commas?
Brad