On Sun, Aug 21, 2011 at 1:37 AM, Gregory Ewing
<greg.ew...@canterbury.ac.nz> wrote:
> There's a certain accounting package I work with that *does*
> use floats -- binary ones -- for accounting purposes, and
> somehow manages to get away with it. Not something I would
> recommend trying at home, though.
>

Probably quite a few, actually. It's not a very visible problem so
long as you always have plenty of "spare precision", and you round
everything off to two decimals (or however many for your currency).
Eventually you'll start seeing weird results that are a cent off, but
you won't notice them often. And hey. You store $1.23 as 1.23, and it
just works! It must be the right thing to do!

Me, I store dollars-and-cents currency in cents. Always. But that's
because I never need fractional cents. I'm not sure what the best way
to handle fractional cents is, but I'm fairly confident that this
isn't it:

http://thedailywtf.com/Articles/Price-in-Nonsense.aspx

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to