def size_to_str(b: int) -> str:
    """Format a number of bytes as a string in B/KB/MB/GB"""
    postfixes = ['B','KB','MB','GB']
    vals = [b / (1000 ** p) for p in range(4)]
    v = min([x for x in vals if x >= 1])
    return f"{v:0.2f} {postfixes[vals.index(v)]}"