views:

114

answers:

1

I am curious which one would be better fitting as a currency field ? I will do simple operations such as taking difference, the percentage between old and new prices. I plan to keep two digits after the zero (ie 10.50) and majority of the time if these digits are zero, I will be hiding these numbers and display it as "10"

ps: Currency is NOT dollar based :)

+6  A: 

Always use DecimalField for money. Even simple operations (addition, subtraction) are not immune to float rounding issues:

>>> 10.50 - 0.20
10.300000000000001

>>> Decimal('10.50') - Decimal('0.20')
Decimal('10.30')
Seth