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 #}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32955>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
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 #}
> }}}
>
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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32955#comment:1>
* status: new => closed
* type: Uncategorized => Bug
* resolution: => invalid
* easy: 1 => 0
Comment:
`widthratio` uses built-in `round()` on floats so it's not really a bug,
see [https://docs.python.org/3/library/functions.html#round a note in
round()'s docs].
--
Ticket URL: <https://code.djangoproject.com/ticket/32955#comment:2>