I am trying to round a decimal number this is my number and my code
68.125
the output should be 68.13 and I get 68.12
code:
{% set v_cuotas = doc.saldo_contrato/doc.plazo %}
VALUE: <span class="texto_liviano"></span>{{v_cuotas|round(2)|float}}<br>
Thanks in advance
A minimal example, that produces the desired rounding looks like this:
>>> from decimal import Decimal, ROUND_HALF_UP
>>> Decimal(Decimal('68.125').quantize(Decimal('0.01'), rounding=ROUND_HALF_UP))
Decimal('68.13')
You can also write acustom Jinja filter if you want use it the same way like the built in round
filter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.