diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2020-02-23 14:37:02 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-02-26 16:02:53 +0100 |
| commit | bc1c03407649a37a8a3c26b8d0cb355ab2fc128e (patch) | |
| tree | 57044fa8e1f991b6a57395dc2679465d87147d81 /django/utils/numberformat.py | |
| parent | 667f784baab31f11d2469e5d22bbdc2390dbc030 (diff) | |
Fixed #28280 -- Prevented numberformat.format() from formatting large/tiny floats in scientific notation.
Diffstat (limited to 'django/utils/numberformat.py')
| -rw-r--r-- | django/utils/numberformat.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py index 961a60e37d..3bfdb2ea52 100644 --- a/django/utils/numberformat.py +++ b/django/utils/numberformat.py @@ -26,6 +26,9 @@ def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='', return mark_safe(number) # sign sign = '' + # Treat potentially very large/small floats as Decimals. + if isinstance(number, float) and 'e' in str(number).lower(): + number = Decimal(str(number)) if isinstance(number, Decimal): if decimal_pos is not None: |
