import math


def format_bytes(input_bytes, precision=2):
    """
    Format an integer number of input_bytes to a human
    readable string.

    If input_bytes is negative, this method raises ArithmeticError
    """

    if input_bytes < 0:
        raise ArithmeticError("Only Positive Integers Allowed")

    if input_bytes != 0:
        exponent = math.floor(math.log(input_bytes, 1024))
    else:
        exponent = 0

    return "%.*f%s" % (
        precision,
        input_bytes / (1024 ** exponent),
        ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'][int(exponent)]
    )