Why not FP for Money?

Batista, Facundo FBatista at uniFON.com.ar
Tue Sep 21 09:05:46 EDT 2004


[Barkmann at gmail.com]

#- I've seen it suggested various times that one should use fixed point
#- for money, perhaps micro cents represented as integers. However, if
#- you do that, you need to make sure you do all the rounding correctly.
#- If you were to use FP, you could have your IEEE 754 hardware do the
#- rounding for you, and get better performance to boot. If you are
#- rounding to cents at the end anyway, I can't see that the 
#- errors you'd
#- get with 64 bit FP numbers would ever be an issue.

Here's a confusion. Floating Point is fine to use in Money. But Decimal
Floating Point, and not Binary Floating Point (DFP is implemented in the
decimal module, BFP is implemented in the IEEE 754 hardware).

For further reference you may read the PEP 327 (Decimal Data Type):

	http://www.python.org/peps/pep-0327.html

Having read the *long* thread from this weekend, and seeing another start,
I'd recommend a *lot* of people to read that PEP.

.	Facundo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040921/b0b4f350/attachment.html>


More information about the Python-list mailing list