コード例 #1
0
def test_negation():
    assert BinaryUtils.neg('1' * 32) == '0' * 32
    assert BinaryUtils.neg('0' * 32) == '1' * 32
コード例 #2
0
    def _from_binary(cls, value):
        if value[0] == '0':
            return int(value, 2)

        neg = int(BinaryUtils.neg(value), 2)
        return -(neg + 1)