Money data type (was: Why not FP for Money?)

Batista, Facundo FBatista at
Mon Sep 27 16:58:26 CEST 2004

[Carlos Ribeiro]

#- As far as money representation is concerned, it's really a 
#- fixed point
#- decimal. But while discussing it here, I see less and less need of
#- native support form fixed point decimals. I think that in 
#- the long run
#- the current Decimals will prove more than enough for the task of
#- handling generic floating point numbers, and that includes money
#- amounts as a special case. But it's too early to tell.

AFIK, achieving fixed point data type is far more complicated that getting
to a Money (or Currency) data type, because you don't do a lot of math with

The other day, I sketched in my mind some basic needs for Money:

- Fixed point
- Representation: $1,234.09 or 1234,09EU$, for example, according to
location and context settings
- Different roundings (seteable by context)

It'll support the operations:

- Add (Money to Money)
- Sub (Money to Money)
- Multiply (Money to Decimal or int/long)
- Divide, taking into account that returns a tuple with values (if it's
called ``divide`` or if ``/`` is allowed is a discussion for later):
    Money(10).divide(3) -> (Money(3.33), Money(3.33), Money(3.34))
- *That's all*

I'll surely write it over Decimal.

Someday I'll write a PEP to collect feedback from all of you (but if you
want to start it, be my guest, ;).

.	Facundo


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list