Alternative to Decimal type

Frank Millman frank at chagford.com
Mon Jun 9 05:36:25 EDT 2008


On Jun 9, 10:54 am, Paul Hankin <paul.han... at gmail.com> wrote:
>
> Hi Frank,
> I don't know why you think Decimal is complicated: it has some
> advanced features, but for what you seem to be doing it should be easy
> to replace your 'Number' with it. In fact, it makes things simpler
> since you don't have to worry about 'scale'.
>
> Your examples convert easily:
>
> from decimal import Decimal
> qty = Decimal('12.5')
> price = Decimal('123.45')
>
> print price * qty
> print qty * price
> print (qty * price).quantize(Decimal('0.01'))
>

I thought I might be missing something obvious. This does indeed look
easy. Thanks, Paul

Frank



More information about the Python-list mailing list