[Django] #30761: The floatformat filter sometimes returns "-0" instead of "0"

10 views
Skip to first unread message

Django

unread,
Sep 4, 2019, 8:55:33 PM9/4/19
to django-...@googlegroups.com
#30761: The floatformat filter sometimes returns "-0" instead of "0"
-------------------------------------+-------------------------------------
Reporter: Sky | Owner: Sky Christensen
Christensen |
Type: Bug | Status: assigned
Component: Template | Version: 2.2
system |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
For values between 0 and -0.5, the floatformat filter returns "-0" where I
would expect it to return "0".

For example:

{{{
$ python -m django --version
2.2.5
$ ./manage.py shell
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.template.defaultfilters import floatformat
>>> floatformat(-0.1, 0)
'-0'
>>> floatformat(-0.01, 1)
'-0.0'
>>> floatformat(-0.001, 2)
'-0.00'
>>> floatformat(-0.4, 0)
'-0'
}}}

If others agree that this is a bug, I'll submit a patch.

--
Ticket URL: <https://code.djangoproject.com/ticket/30761>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 4, 2019, 9:11:22 PM9/4/19
to django-...@googlegroups.com
#30761: The floatformat filter sometimes returns "-0" instead of "0"
-------------------------------------+-------------------------------------
Reporter: Sky Christensen | Owner: Sky

| Christensen
Type: Bug | Status: assigned
Component: Template system | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sky Christensen):

* owner: Sky Christensen => Sky Christensen


--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:1>

Django

unread,
Sep 5, 2019, 2:11:50 AM9/5/19
to django-...@googlegroups.com
#30761: The floatformat filter sometimes returns "-0" instead of "0".

-------------------------------------+-------------------------------------
Reporter: Sky Christensen | Owner: Sky
| Christensen
Type: Bug | Status: closed

Component: Template system | Version: 2.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: assigned => closed
* resolution: => wontfix


Comment:

I don't think it's an issue, this behavior is consistent with builtin
`round()` and `-0` exists in floating-point arithmetic.

--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:2>

Django

unread,
Sep 26, 2019, 11:13:52 PM9/26/19
to django-...@googlegroups.com
#30761: The floatformat filter sometimes returns "-0" instead of "0".
-------------------------------------+-------------------------------------
Reporter: Sky Christensen | Owner: Sky
| Christensen
Type: Bug | Status: new

Component: Template system | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sky Christensen):

* status: closed => new
* resolution: wontfix =>


Comment:

Re-opening following a discussion on the django-developers mailing list.

--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:3>

Django

unread,
Sep 26, 2019, 11:21:15 PM9/26/19
to django-...@googlegroups.com
#30761: The floatformat filter sometimes returns "-0" instead of "0".
-------------------------------------+-------------------------------------
Reporter: Sky Christensen | Owner: Sky
| Christensen
Type: Bug | Status: assigned
Component: Template system | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sky Christensen):

* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:4>

Django

unread,
Sep 27, 2019, 2:48:28 AM9/27/19
to django-...@googlegroups.com
#30761: The floatformat filter sometimes returns "-0" instead of "0".
-------------------------------------+-------------------------------------
Reporter: Sky Christensen | Owner: Sky
| Christensen
Type: Bug | Status: assigned
Component: Template system | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:5>

Django

unread,
Oct 30, 2019, 10:57:28 PM10/30/19
to django-...@googlegroups.com
#30761: The floatformat filter sometimes returns "-0" instead of "0".
-------------------------------------+-------------------------------------
Reporter: Sky Christensen | Owner: Sky
| Christensen
Type: Bug | Status: assigned
Component: Template system | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sky Christensen):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/11997

--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:6>

Django

unread,
Oct 31, 2019, 2:35:30 AM10/31/19
to django-...@googlegroups.com
#30761: The floatformat filter sometimes returns "-0" instead of "0".
-------------------------------------+-------------------------------------
Reporter: Sky Christensen | Owner: Sky
| Christensen
Type: Bug | Status: assigned
Component: Template system | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Johannes Hoppe):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:7>

Django

unread,
Oct 31, 2019, 4:44:14 AM10/31/19
to django-...@googlegroups.com
#30761: The floatformat filter sometimes returns "-0" instead of "0".
-------------------------------------+-------------------------------------
Reporter: Sky Christensen | Owner: Sky
| Christensen
Type: Bug | Status: assigned
Component: Template system | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 1 => 0


Comment:

[https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!searchin
/django-developers/floatformat%7Csort:date/django-
developers/n6Qtwi3N60g/De6wJ4FFBAAJ Discussion]

--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:8>

Django

unread,
Oct 31, 2019, 6:15:21 AM10/31/19
to django-...@googlegroups.com
#30761: The floatformat filter sometimes returns "-0" instead of "0".
-------------------------------------+-------------------------------------
Reporter: Sky Christensen | Owner: Sky
| Christensen
Type: Bug | Status: closed

Component: Template system | Version: 2.2
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed

* resolution: => fixed


Comment:

In [changeset:"3cf907c20c4f4d94f649fbb93a006af5c61b30b8" 3cf907c2]:
{{{
#!CommitTicketReference repository=""
revision="3cf907c20c4f4d94f649fbb93a006af5c61b30b8"
Fixed #30761 -- Prevented floatformat filter from returning a negative
zero.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:9>

Reply all
Reply to author
Forward
0 new messages