examples

Test suite containing examples and functional unit tests (based on bit vector implementations of common arithmetic operations) that demonstrate how this library’s features can be used.

To view the source code of an example function, click its [source] link.

add(x: bitlist, y: bitlist) bitlist[source]

Bitwise addition algorithm.

>>> int(add(bitlist(123), bitlist(456)))
579
mul(x: bitlist, y: bitlist) bitlist[source]

Bitwise multiplication algorithm.

>>> int(mul(bitlist(123), bitlist(456)))
56088
exp(x: bitlist, y: bitlist) bitlist[source]

Bitwise exponentiation algorithm.

>>> int(exp(bitlist(123), bitlist(5)))
28153056843
div(x: bitlist, y: bitlist) bitlist[source]

Bitwise integer division algorithm.

>>> int(div(bitlist(12345), bitlist(678)))
18