def pretty_size(num, divisor=1024.0):
    """Given a number of bytes, determines the correct suffix and formats it

    Args:
        num (float): The number of bytes
        divisor (int, optional): The cutoff before the next suffix is used

    Returns:
        str: `num` formatted with a suffix
    Examples:
        >>> pretty_size(1023)
        '1023.0bytes'
        >>> pretty_size(1024)
        '1.0KB'
        >>> pretty_size(5368709120)
        '5.0GB'
        >>> pretty_size(5368709120, 100.0)
        '53.7TB'
        >>> pretty_size(-5368709120, 100.0)
        '-53.7TB'
    """
    for x in ('bytes', 'KB', 'MB', 'GB', 'TB'):
        if divisor > num > -divisor:
            return "%3.1f%s" % (num, x)
        num /= divisor
    return "%3.1f%s" % (num, 'PB')