| 1109 | | * ``36.123`` gets converted to ``36.1`` |
|---|
| 1110 | | * ``36.15`` gets converted to ``36.2`` |
|---|
| 1111 | | * ``36`` gets converted to ``36`` |
|---|
| 1112 | | |
|---|
| 1113 | | If used with a numeric integer argument, ``floatformat`` rounds a number to that |
|---|
| 1114 | | many decimal places. For example: |
|---|
| 1115 | | |
|---|
| 1116 | | * ``36.1234`` with floatformat:3 gets converted to ``36.123`` |
|---|
| 1117 | | * ``36`` with floatformat:4 gets converted to ``36.0000`` |
|---|
| 1118 | | |
|---|
| 1119 | | If the argument passed to ``floatformat`` is negative, it will round a number to |
|---|
| 1120 | | that many decimal places -- but only if there's a decimal part to be displayed. |
|---|
| 1121 | | For example: |
|---|
| 1122 | | |
|---|
| 1123 | | * ``36.1234`` with floatformat:-3 gets converted to ``36.123`` |
|---|
| 1124 | | * ``36`` with floatformat:-4 gets converted to ``36`` |
|---|
| 1125 | | |
|---|
| 1126 | | Using ``floatformat`` with no argument is equivalent to using ``floatformat`` with |
|---|
| 1127 | | an argument of ``-1``. |
|---|
| | 1109 | ======== ======================= ====== |
|---|
| | 1110 | value Template Output |
|---|
| | 1111 | ======== ======================= ====== |
|---|
| | 1112 | 34.23234 {{ value|floatformat }} 34.2 |
|---|
| | 1113 | 34.00000 {{ value|floatformat }} 34 |
|---|
| | 1114 | 34.26000 {{ value|floatformat }} 34.3 |
|---|
| | 1115 | ======== ======================= ====== |
|---|
| | 1116 | |
|---|
| | 1117 | If used with a numeric integer argument, ``floatformat`` rounds a number to |
|---|
| | 1118 | that many decimal places. For example: |
|---|
| | 1119 | |
|---|
| | 1120 | ======== ========================= ====== |
|---|
| | 1121 | value Template Output |
|---|
| | 1122 | ======== ========================= ====== |
|---|
| | 1123 | 34.23234 {{ value|floatformat:3 }} 34.232 |
|---|
| | 1124 | 34.00000 {{ value|floatformat:3 }} 34.000 |
|---|
| | 1125 | 34.26000 {{ value|floatformat:3 }} 34.260 |
|---|
| | 1126 | ======== ========================= ====== |
|---|
| | 1127 | |
|---|
| | 1128 | If the argument passed to ``floatformat`` is negative, it will round a number |
|---|
| | 1129 | to that many decimal places -- but only if there's a decimal part to be |
|---|
| | 1130 | displayed. For example: |
|---|
| | 1131 | |
|---|
| | 1132 | ======== ============================ ====== |
|---|
| | 1133 | value Template Output |
|---|
| | 1134 | ======== ============================ ====== |
|---|
| | 1135 | 34.23234 {{ value|floatformat:"-3" }} 34.232 |
|---|
| | 1136 | 34.00000 {{ value|floatformat:"-3" }} 34 |
|---|
| | 1137 | 34.26000 {{ value|floatformat:"-3" }} 34.260 |
|---|
| | 1138 | ======== ============================ ====== |
|---|
| | 1139 | |
|---|
| | 1140 | Using ``floatformat`` with no argument is equivalent to using ``floatformat`` |
|---|
| | 1141 | with an argument of ``-1``. |
|---|