mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #27394 -- Added scientific notation support for big integers in floatformat filter.
This commit is contained in:
committed by
Tim Graham
parent
9e4fd3301d
commit
12f7928f5a
@@ -134,7 +134,7 @@ def floatformat(text, arg=-1):
|
||||
"""
|
||||
|
||||
try:
|
||||
input_val = force_text(text)
|
||||
input_val = repr(text)
|
||||
d = Decimal(input_val)
|
||||
except UnicodeEncodeError:
|
||||
return ''
|
||||
@@ -165,7 +165,8 @@ def floatformat(text, arg=-1):
|
||||
try:
|
||||
# Set the precision high enough to avoid an exception, see #15789.
|
||||
tupl = d.as_tuple()
|
||||
units = len(tupl[1]) - tupl[2]
|
||||
units = len(tupl[1])
|
||||
units += -tupl[2] if m else tupl[2]
|
||||
prec = abs(p) + units + 1
|
||||
|
||||
# Avoid conversion to scientific notation by accessing `sign`, `digits`
|
||||
|
||||
Reference in New Issue
Block a user