Skip to content

Commit

Permalink
Fix memory calculation algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Jan 5, 2025
1 parent bb05d9d commit 2bbbd8d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyarchitecture/squire.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def size_converter(byte_size: int | float) -> str:
str:
Converted human-readable size.
"""
if byte_size:
if byte_size > 0:
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
index = int(math.floor(math.log(byte_size, 1024)))
index = min(int(math.floor(math.log(byte_size, 1024))), len(size_name) - 1)
return (
f"{format_nos(round(byte_size / pow(1024, index), 2))} {size_name[index]}"
)
Expand Down

0 comments on commit 2bbbd8d

Please sign in to comment.