diff --git a/pyarchitecture/squire.py b/pyarchitecture/squire.py index 74b3d57..e087b5a 100644 --- a/pyarchitecture/squire.py +++ b/pyarchitecture/squire.py @@ -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]}" )