@staticmethod
def _bin_to_int(v: str, num_value_bits: int) ->int:
    """Converts a binary string of n bits using two's complement to an integer."""
    if v.startswith('1'):
        int_v = int(v, 2) - 2 ** num_value_bits
    else:
        int_v = int(v, 2)
    return int_v
