[Python-ideas] Decimal literal?

Adam Olsen rhamph at gmail.com
Thu Dec 4 19:18:49 CET 2008


On Thu, Dec 4, 2008 at 3:19 AM, Cesare Di Mauro
<cesare.dimauro at a-tono.com> wrote:
> But working with financial applications, using decimal numerics
> is a very common practice. Even if implementation is slow, we
> prefer exact results over speed: there must be no possibility on
> failing calculations when we are manipulating moneys.

This has always bothered me: the suggestion that decimal *floats* are
suitable for financial calculations, when fixed point is what you
want.  However, I now see some FAQ entries in
http://docs.python.org/library/decimal.html that show how to get fixed
point behaviour out of it.  Including a wrapper around multiply and
divide, for ease of use, heh.

Regardless, although financial use cases are important, their
behaviour is not universal.  The next country over or a few years down
the road may have different rules, different proportions, etc.  Not
something we want to hardcode.


-- 
Adam Olsen, aka Rhamphoryncus



More information about the Python-ideas mailing list