Merge pull request #601 from SchrodingersGat/trailing-fix

Trailing fix
This commit is contained in:
Oliver 2020-01-02 20:32:16 +11:00 committed by GitHub
commit d2d5909701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,8 +65,19 @@ def decimal2string(d):
A string representation of the input number
"""
try:
# Ensure that the provided string can actually be converted to a float
float(d)
except ValueError:
# Not a number
return str(d)
s = str(d)
# Return entire number if there is no decimal place
if '.' not in s:
return s
return s.rstrip("0").rstrip(".")