#32955: widthratio does not round properly
---------------------------------+--------------------------------------
Reporter: alfonsrv | Owner: nobody
Type: Uncategorized | Status: new
Component: Template system | Version: 3.1
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
---------------------------------+--------------------------------------
Description changed by alfonsrv:
Old description:
> The documentation states, quote
>
> 175/200 = .875; .875 * 100 = 87.5 which is rounded up to 88
>
> Using the example provided in the official documentation produces 88px.
> However when dividing 5/2, it results in 2 instead of what I would expect
> to be 3.
>
> {{{
> {% widthratio 5 2 1 as width %}
> The width is: {{ width }} {# results in 2 instead of 3 #}
> }}}
>
> https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#:~:text=87.5%20which%20is%20rounded%20up%20to%2088
New description:
The documentation states, quote
175/200 = .875; .875 * 100 = 87.5 which is rounded up to 88
Using the example provided in the official documentation produces 88px.
However when dividing 5/2, it results in 2 instead of what I would expect
to be 3.
{{{
{% widthratio 5 2 1 as width %}
The width is: {{ width }} {# results in 2 instead of 3 #}
}}}
When using 7 instead of 5, the width results in the expected 4.
https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#:~:text=87.5%20which%20is%20rounded%20up%20to%2088
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32955#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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.3602cb7b5dd79a50f74053e29b4d13a9%40djangoproject.com.