Skip to content

Commit

Permalink
metric: Fix precision format
Browse files Browse the repository at this point in the history
  • Loading branch information
e-nikolov authored Dec 3, 2023
1 parent 5cb0323 commit c0e5f1c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/humanize/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def metric(value: float, unit: str = "", precision: int = 3) -> str:
ordinal_ = "mμnpfazyrq"[(-exponent - 1) // 3]
else:
ordinal_ = ""
value_ = format(value, ".%if" % (precision - (exponent % 3) - 1))
value_ = format(value, ".%if" % max(0, precision - (exponent % 3) - 1))
if not (unit or ordinal_) or unit in ("°", "′", "″"):
space = ""
else:
Expand Down

0 comments on commit c0e5f1c

Please sign in to comment.