Added pretty tables for `floatformat` documentation.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6648 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Gary Wilson Jr 2007-11-04 02:48:44 +00:00
parent a5eb61cd9f
commit 6f7fd897bc
1 changed files with 28 additions and 14 deletions

View File

@ -1106,25 +1106,39 @@ floatformat
When used without an argument, rounds a floating-point number to one decimal When used without an argument, rounds a floating-point number to one decimal
place -- but only if there's a decimal part to be displayed. For example: place -- but only if there's a decimal part to be displayed. For example:
* ``36.123`` gets converted to ``36.1`` ======== ======================= ======
* ``36.15`` gets converted to ``36.2`` value Template Output
* ``36`` gets converted to ``36`` ======== ======================= ======
34.23234 {{ value|floatformat }} 34.2
34.00000 {{ value|floatformat }} 34
34.26000 {{ value|floatformat }} 34.3
======== ======================= ======
If used with a numeric integer argument, ``floatformat`` rounds a number to that If used with a numeric integer argument, ``floatformat`` rounds a number to
many decimal places. For example: that many decimal places. For example:
* ``36.1234`` with floatformat:3 gets converted to ``36.123`` ======== ========================= ======
* ``36`` with floatformat:4 gets converted to ``36.0000`` value Template Output
======== ========================= ======
34.23234 {{ value|floatformat:3 }} 34.232
34.00000 {{ value|floatformat:3 }} 34.000
34.26000 {{ value|floatformat:3 }} 34.260
======== ========================= ======
If the argument passed to ``floatformat`` is negative, it will round a number to If the argument passed to ``floatformat`` is negative, it will round a number
that many decimal places -- but only if there's a decimal part to be displayed. to that many decimal places -- but only if there's a decimal part to be
For example: displayed. For example:
* ``36.1234`` with floatformat:-3 gets converted to ``36.123`` ======== ============================ ======
* ``36`` with floatformat:-4 gets converted to ``36`` value Template Output
======== ============================ ======
34.23234 {{ value|floatformat:"-3" }} 34.232
34.00000 {{ value|floatformat:"-3" }} 34
34.26000 {{ value|floatformat:"-3" }} 34.260
======== ============================ ======
Using ``floatformat`` with no argument is equivalent to using ``floatformat`` with Using ``floatformat`` with no argument is equivalent to using ``floatformat``
an argument of ``-1``. with an argument of ``-1``.
get_digit get_digit
~~~~~~~~~ ~~~~~~~~~