FloatField values get rounded on save()
|Reported by:||rfugger at gmail dot com||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Django uses the %s format code to insert FloatField values into SQL command strings to send to the database. However, the %s format code rounds floating point numbers to 12 significant digits, which may cause unexpected rounding when the FloatField is configured to store more than 12 digits.
I would have expected Django to use the '%.xf' format code, where x = decimal_places specified for the FloatField in the model definition, which would prevent rounding when saving to the database.
Change History (5)
comment:1 Changed 8 years ago by rfugger at gmail dot com
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 8 years ago by Michael Radziej <mir@…>
- Triage Stage changed from Unreviewed to Design decision needed