def METHOD_NAME(
        num,
        unit: str = 'B',
        binary: bool = False,
        precision: int = 2,
) -> str:
    if binary:
        factor = 1024
        affix = 'i'
    else:
        factor = 1000
        affix = ''
    for prefix in ('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z'):
        if abs(num) < factor:
            break
        num /= factor
    else:
        prefix = 'Y'
    return f'{num:3.{precision}f} {prefix}{affix}{unit}'