Python, databases, floating point, and money

Laura Creighton lac at strakt.com
Fri Dec 6 16:45:28 EST 2002


Check out http://fixedpoint.sourceforge.net/

Laura Creighton

> What is the accepted method of dealing with monetary calculations and
> databases, specifically in Python, but also in general?  I know that
> there are floating point types, but it seems to me that their
> imprecision would cause significant problems when dealing with monetary
> quantities, once those numbers get very large at all.
> 
> One scheme I've thought of is to use two fields - an integer (probably
> 64bit, internally represented as a Python long) representing the
> quantity, and then another integer field that has the number of places
> to the right of the zero (i.e., the power of 10 to divide by to get the
> true number).  But it seems like this would be horribly non-standard.
> 
> How do existing applications cope with this?
> 
> Thanks,
> Michael
> -- 
> http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list