Exemplo n.º 1
0
Arquivo: job.py Projeto: ybc1991/Cirq
def _little_endian_to_big(value: int, bit_count: int) -> int:
    return cirq.big_endian_bits_to_int(
        cirq.big_endian_int_to_bits(value, bit_count=bit_count)[::-1])
Exemplo n.º 2
0
def test_big_endian_bits_to_int():
    assert cirq.big_endian_bits_to_int([0, 1]) == 1
    assert cirq.big_endian_bits_to_int([1, 0]) == 2
    assert cirq.big_endian_bits_to_int([0, 1, 0]) == 2
    assert cirq.big_endian_bits_to_int([1, 0, 0, 1, 0]) == 18

    assert cirq.big_endian_bits_to_int([]) == 0
    assert cirq.big_endian_bits_to_int([0]) == 0
    assert cirq.big_endian_bits_to_int([0, 0]) == 0
    assert cirq.big_endian_bits_to_int([0, 0, 0]) == 0

    assert cirq.big_endian_bits_to_int([1]) == 1
    assert cirq.big_endian_bits_to_int([0, 1]) == 1
    assert cirq.big_endian_bits_to_int([0, 0, 1]) == 1