Commit d5c3c45f authored by Daniel Greenfeld's avatar Daniel Greenfeld
Browse files

Demonstrate how to round to integers using floatformat templatetag

parent 8d3f932f
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1517,6 +1517,17 @@ displayed. For example:
``34.26000``  ``{{ value|floatformat:"-3" }}``  ``34.260``
============  ================================  ==========

If the argument passed to ``floatformat`` is 0 (zero), it will round the number
to the nearest integer.

============  ================================  ==========
``value``     Template                          Output
============  ================================  ==========
``34.23234``  ``{{ value|floatformat:"0" }}``   ``34``
``34.00000``  ``{{ value|floatformat:"0" }}``   ``34``
``39.56000``  ``{{ value|floatformat:"0" }}``   ``40``
============  ================================  ==========

Using ``floatformat`` with no argument is equivalent to using ``floatformat``
with an argument of ``-1``.