Opened 6 years ago

Last modified 6 years ago

#29130 closed Bug

floatformat is rounding off incorrectly — at Version 1

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 )

Change History (2)

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?

Note: See TracTickets for help on using tickets.
Back to Top