Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

float field vs decimal field in django models

# 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')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #float #field #decimal #field #django #models
ADD COMMENT
Topic
Name
1+9 =