Currency format for floats?

Neel Krishnaswami neelk at brick.cswv.com
Fri Jun 2 19:08:37 EDT 2000


Joseph Santaniello <joseph at src.no> wrote:
> 
> I gave up on a locale way, but this is just what I needed. Thanks
> everybody!
 
The original post didn't show up on my machine, so I'm responding
to this followup. 

Let me caution you against using floating point numbers when dealing
with money amounts -- the rounding errors that can accumulate can
make reconciling your accounting records a PITA.

You are much better off storing money as an integer, denominated in
pennies (or whatever the equivalent minimal integral unit is for the
kroner). Or, if you really want to apparently use floating point, I'd
use a real fixed-point arithmetic class, an implementation of which
Tim Peters posted to the list in the past year. (Deja's archives are
down, as is the python.org search, or I'd give you a URL to
it. Hopefully Tim will followup with a repost....)



Neel





More information about the Python-list mailing list