Fix crash when printing 0 in human-readable format

Resolves #3787
This commit is contained in:
Elliot Larez authored and GitHub committed 2026-09-18 18:45:33 -04:00
1 parent 50e0e3c70c
commit b96534794d
1 file changed
+6
+6
View File
@@ -37,6 +37,12 @@ def human_format(num):
Args:
num: number to format
"""
# Prevents math domain error
if num == 0:
return "0.00"
if num < 0:
return f"-{human_format(-num)}"
units = ["", "K", "M", "B", "T", "P"]
k = 1000.0
magnitude = int(floor(log(num, k)))