Commit af655e61 authored by Jérome Perrin's avatar Jérome Perrin

if precision is defined on the field, use this precision to format; only use

repr if no precision is defined. If number is so big that it can only be
displayed in scientific notation, return it as is.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34755 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f0171be5
......@@ -1649,11 +1649,17 @@ class FloatWidget(TextWidget):
try :
float_value = float(value)
if precision not in (None, ''):
float_value = round(float_value, precision)
# we use repr that have a better precision than str
# if we have a precision, then use it now
value = ('%%0.%sf' % precision) % float_value
else:
# if no precision, we use repr which have a better precision than str
value = repr(float_value)
except ValueError:
return value
# if this number displayed in scientific notification, just return it as
# is
if 'e' in value:
return value
value_list = value.split('.')
integer = value_list[0]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment