summaryrefslogtreecommitdiff
path: root/representer.py
diff options
context:
space:
mode:
authorRolf Wojtech <rolf@wojtech.de>2018-03-22 01:00:15 +0100
committerRolf Wojtech <rolf@wojtech.de>2018-03-22 01:00:15 +0100
commit13a883ccbdcba12f942c134aceb9e38fe70f372f (patch)
treeb99cfd4cb899defac244a4e22d73249bb64d2fb5 /representer.py
parent66b44b72d4be2a975c45d1d84bec80b10e3184da (diff)
downloadruamel.yaml-13a883ccbdcba12f942c134aceb9e38fe70f372f.tar.gz
Consider m_sign when calculating precision
Together with the last commit this fixes the loss of precision when handling floats in scientic notation.
Diffstat (limited to 'representer.py')
-rw-r--r--representer.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/representer.py b/representer.py
index 9163637..fddfa3c 100644
--- a/representer.py
+++ b/representer.py
@@ -782,7 +782,7 @@ class RoundTripRepresenter(SafeRepresenter):
value += u'0'
else:
# exponent
- m, es = u'{:{}.{}e}'.format(data, data._width, data._width - data._prec).split('e')
+ m, es = u'{:{}.{}e}'.format(data, data._width, data._width - data._prec + (1 if data._m_sign else 0)).split('e')
w = data._width if data._prec > 0 else (data._width + 1)
if data < 0:
w += 1