Binary operations#

Elementwise bit operations#

bitwise_and(x1, x2, /[, out, casting, dtype])

Computes the bitwise AND of two arrays elementwise.

bitwise_or(x1, x2, /[, out, casting, dtype])

Computes the bitwise OR of two arrays elementwise.

bitwise_xor(x1, x2, /[, out, casting, dtype])

Computes the bitwise XOR of two arrays elementwise.

invert(x, /[, out, casting, dtype])

Computes the bitwise NOT of an array elementwise.

left_shift(x1, x2, /[, out, casting, dtype])

Shifts the bits of each integer element to the left.

right_shift(x1, x2, /[, out, casting, dtype])

Shifts the bits of each integer element to the right.

Bit packing#

packbits(a[, axis, bitorder])

Packs the elements of a binary-valued array into bits in a uint8 array.

unpackbits(a[, axis, bitorder])

Unpacks elements of a uint8 array into a binary-valued output array.

Output formatting#

binary_repr(num[, width])

Return the binary representation of the input number as a string.