Opened 6 years ago

Closed 6 years ago

#29130 closed Bug (invalid)

floatformat is rounding off incorrectly

Reported by: Akash Deshpande Owned by: nobody
Component: Template system Version: 1.11
Severity: Normal Keywords: template float filter
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

I think 12f7928f5a455e330c0a7f19bc86b37baca12811 caused a regression in floatformat.

{{ 331.44999999999|floatformat:-1 }}

The above should return 331.5, but returns 331.4. This changed in django 1.11. (It returned 331.5 in django 1.8.X )

Attachments (1)

Screen Shot 2018-02-12 at 1.49.17 PM.png (32.1 KB ) - added by Akash Deshpande 6 years ago.

Download all attachments as: .zip

Change History (3)

by Akash Deshpande, 6 years ago

comment:1 by Tim Graham, 6 years ago

Description: modified (diff)
Summary: Floatformat is rounding off incorrectly.floatformat is rounding off incorrectly

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?

comment:2 by Tim Graham, 6 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top