Skip to content

Commit

Permalink
limit float stringification
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Jan 9, 2025
1 parent 6b50457 commit ef623d1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion normality/stringify.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def stringify(
if isinstance(value, (date, datetime)):
return value.isoformat()
elif isinstance(value, float):
return str(value)
# Avoid trailing zeros and limit to 3 decimal places:
return format(value, ".3f").rstrip("0").rstrip(".")
elif isinstance(value, Decimal):
return Decimal(value).to_eng_string()
elif isinstance(value, bytes):
Expand Down

0 comments on commit ef623d1

Please sign in to comment.