[Django] #29130: Floatformat is rounding off incorrectly.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #29130: Floatformat is rounding off incorrectly.

Django
#29130: Floatformat is rounding off incorrectly.
-------------------------------------+-------------------------------------
               Reporter:  Akash      |          Owner:  nobody
  Deshpande                          |
                   Type:  Bug        |         Status:  new
              Component:  Template   |        Version:  1.11
  system                             |       Keywords:  template float
               Severity:  Normal     |  filter
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 I think the below changes broke/caused issues in floatformat

 https://github.com/django/django/commit/12f7928f5a455e330c0a7f19bc86b37baca12811

 Easiest way to replicate the issue is
 1. Create a simple view with a template

 views.py
 \\
    def test(request):
         return render('test.html')


 test.html
 \\
          {{ 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 )

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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/052.fc3f751747935841d2bc206c9a00f867%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29130: Floatformat is rounding off incorrectly.

Django
#29130: Floatformat is rounding off incorrectly.
-------------------------------------+-------------------------------------
     Reporter:  Akash Deshpande      |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Template system      |                  Version:  1.11
     Severity:  Normal               |               Resolution:
     Keywords:  template float       |             Triage Stage:
  filter                             |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Akash Deshpande):

 * Attachment "Screen Shot 2018-02-12 at 1.49.17 PM.png" added.


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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.0f25e6a566a032ecafaaf5955ba1acbd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29130: floatformat is rounding off incorrectly (was: Floatformat is rounding off incorrectly.)

Django
In reply to this post by Django
#29130: floatformat is rounding off incorrectly
-------------------------------------+-------------------------------------
     Reporter:  Akash Deshpande      |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Template system      |                  Version:  1.11
     Severity:  Normal               |               Resolution:
     Keywords:  template float       |             Triage Stage:
  filter                             |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Old description:

> I think the below changes broke/caused issues in floatformat
>
> https://github.com/django/django/commit/12f7928f5a455e330c0a7f19bc86b37baca12811
>
> Easiest way to replicate the issue is
> 1. Create a simple view with a template
>
> views.py
> \\
>    def test(request):
>         return render('test.html')
>

> test.html
> \\
>          {{ 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 )

New description:

 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 )

--

Comment (by Tim Graham):

 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?

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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.d2846c7b99de0c1f763a610c5989fb59%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29130: floatformat is rounding off incorrectly

Django
In reply to this post by Django
#29130: floatformat is rounding off incorrectly
-------------------------------------+-------------------------------------
     Reporter:  Akash Deshpande      |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Template system      |                  Version:  1.11
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  template float       |             Triage Stage:
  filter                             |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

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


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

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.c63ebf528045672162981d5352f7d96e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.