If you assign a float with more decimal places than a DecimalField field 
supports to that field, the value may round differently than if you assign 
the same value as a string. For example:

class Invoice(models.Model):
    gross = models.DecimalField(max_digits=10, decimal_places=1)

invoice.gross = 2.15    # saves as 2.1
invoice.gross = '2.15'  # saves as 2.2

The default behavior of decimal rounding is ROUND_HALF_EVEN (to nearest 
with ties going to nearest even integer). There's a proposal to change this 
to cast floats to string and then use ROUND_HALF_UP to match the value of 
strings [0][1]. Do you have any concerns about this? Is it something we 
should even care about?

[0] https://github.com/django/django/pull/6410
[1] https://code.djangoproject.com/ticket/26459

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/3749bbaf-ded7-4de3-912b-3a9e654b0207%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to