def _calculate_log2_num_bytes(value: int) ->int:
    """
    Determine the number of bytes required to encode the input value.

    Artificially limited to max of 8 bytes to be compliant

    :param value:
    :return: The calculate the number of bytes
    """
    for log2_num_bytes in range(4):
        limit = 1 << (1 << log2_num_bytes) * 8
        if value < limit:
            return log2_num_bytes
    raise RuntimeError(
        'Unable to calculate the number of bytes required for this value')
