def test_from_bin(self): cases = [('1010', [1, 0, 1, 0]), ('111111', [1, 1, 1, 1, 1, 1]), ('0100', [0, 1, 0, 0]), ('0', [0]), ('00', [0, 0])] for q, a in cases: assert Bits.from_bin(q) == Bits(a) assert Bits.from_bin('0b' + q) == Bits(a) with pytest.raises(BitsConstructError): Bits.from_bin('0c100') with pytest.raises(BitsConstructError): Bits.from_bin('0123')
from pybit.bits import Bits from pybit.multiplication import Multiplication X = Bits.from_bin('10111101') Y = Bits.from_bin('10101111') P, G, CO, S = Multiplication.CLA(X, Y, CI0=0, size=8) print("P: ", P.hex) print("G: ", G.hex) print("S: ", S.hex) print("CO: ", CO.hex)