Opened 7 years ago
Closed 7 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 )
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)
Change History (3)
by , 7 years ago
Attachment: | Screen Shot 2018-02-12 at 1.49.17 PM.png added |
---|
comment:1 by , 7 years ago
Description: | modified (diff) |
---|---|
Summary: | Floatformat is rounding off incorrectly. → floatformat is rounding off incorrectly |
comment:2 by , 7 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
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?