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.
* owner: Sky Christensen => Sky Christensen
--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:1>
* 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>
* 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>
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:4>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:5>
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/11997
--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:6>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/30761#comment:7>
* 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>
* 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>