Changes between Initial Version and Version 1 of Ticket #29130


Ignore:
Timestamp:
Feb 12, 2018, 8:25:03 PM (6 years ago)
Author:
Tim Graham
Comment:

The current behavior looks correct to me. If rounding to one decimal place, look at the second decimal place (4). Since that's less than five, round down. Have I misunderstood the rules for rounding?

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #29130

    • Property Summary Floatformat is rounding off incorrectly.floatformat is rounding off incorrectly
  • Ticket #29130 – Description

    initial v1  
    1 I think the below changes broke/caused issues in floatformat
     1I think 12f7928f5a455e330c0a7f19bc86b37baca12811 caused a regression in `floatformat`.
    22
    3  https://github.com/django/django/commit/12f7928f5a455e330c0a7f19bc86b37baca12811
    4 
    5 Easiest way to replicate the issue is
    6 1. Create a simple view with a template
    7 
    8 views.py
    9 \\
    10    def test(request):
    11         return render('test.html')
    12 
    13 
    14 test.html
    15 \\
    16          {{ 331.44999999999|floatformat:-1 }}
     3`{{ 331.44999999999|floatformat:-1 }}`
    174
    185The above should return 331.5, but returns 331.4. This changed in django 1.11. (It returned 331.5 in django 1.8.X )
    19 
    20 
Back to Top