Skip to content

Commit

Permalink
Handle edge case when rounding
Browse files Browse the repository at this point in the history
(cherry picked from commit 316abf8)
  • Loading branch information
tgibson11 committed Oct 19, 2023
1 parent caf16fa commit 79bf044
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions syscore/genutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def round_significant_figures(x: float, figures: int = 3) -> float:
>>> round_significant_figures(0.0234, 2)
0.023
"""
if x == 0:
return 0.0

return round(x, figures - int(math.floor(math.log10(abs(x)))) - 1)


Expand Down

0 comments on commit 79bf044

Please sign in to comment.