Skip to content

Commit 24ef71c

Browse files
authored
Merge pull request greedo#32 from TomLaMantia/master
trim decimal bug when precision is 0
2 parents 19e7c12 + a8b82cd commit 24ef71c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

xbrl/xbrl.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,13 @@ def trim_decimals(s, precision=-3):
660660
encoded = s.encode('ascii', 'ignore')
661661
str_val = ""
662662
if six.PY3:
663-
str_val = str(encoded, encoding='ascii',
664-
errors='ignore')[:precision]
663+
str_val = str(encoded, encoding='ascii', errors='ignore')[:precision]
665664
else:
666-
str_val = str(encoded)[:precision]
665+
# If precision is 0, this must be handled seperately
666+
if precision == 0:
667+
str_val = str(encoded)
668+
else:
669+
str_val = str(encoded)[:precision]
667670
if len(str_val) > 0:
668671
return float(str_val)
669672
else:

0 commit comments

Comments
 (0)