diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 4530adf..9eabb6d 100644
a
|
b
|
def floatformat(text, arg=-1):
|
169 | 169 | # Set the precision high enough to avoid an exception, see #15789. |
170 | 170 | tupl = d.as_tuple() |
171 | 171 | units = len(tupl[1]) - tupl[2] |
172 | | prec = abs(arg) + units + 1 |
| 172 | prec = abs(p) + units + 1 |
173 | 173 | |
174 | 174 | # Avoid conversion to scientific notation by accessing `sign`, `digits` |
175 | 175 | # and `exponent` from `Decimal.as_tuple()` directly. |
diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py
index 5288e50..5e8c8f1 100644
a
|
b
|
class DefaultFiltersTests(TestCase):
|
69 | 69 | try: |
70 | 70 | self.assertEqual(floatformat(1.2345, 2), u'1.23') |
71 | 71 | self.assertEqual(floatformat(15.2042, -3), u'15.204') |
| 72 | self.assertEqual(floatformat(1.2345, '2'), u'1.23') |
| 73 | self.assertEqual(floatformat(15.2042, '-3'), u'15.204') |
72 | 74 | self.assertEqual(floatformat(decimal.Decimal('1.2345'), 2), u'1.23') |
73 | 75 | self.assertEqual(floatformat(decimal.Decimal('15.2042'), -3), u'15.204') |
74 | 76 | finally: |