From 78e52566c69dd15b1c7dc2263da2a913dd77a073 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 4 Nov 2021 08:31:48 -0400 Subject: [PATCH] Use `round()` for magnitude check --- piker/calc.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/piker/calc.py b/piker/calc.py index d5d8d4e1..eb3ef4c6 100644 --- a/piker/calc.py +++ b/piker/calc.py @@ -43,11 +43,15 @@ def humanize( if not number or number <= 0: return round(number, ndigits=digits) - mag = math.floor(math.log(number, 10)) + mag = round(math.log(number, 10)) if mag < 3: return round(number, ndigits=digits) - maxmag = max(itertools.takewhile(lambda key: mag >= key, _mag2suffix)) + maxmag = max( + itertools.takewhile( + lambda key: mag >= key, _mag2suffix + ) + ) return "{value}{suffix}".format( value=round(number/10**maxmag, ndigits=digits),