NumPy includes a package to perform bitwise operations on the array elements. These NumPy bitwise operators perform bit by bit operations. It performs the function of two-bit values to produce a new value. There are functions to convert the elements into their binary representation and then apply operations on the bits.
This is a specific package that applies bitwise operations on the binary format of elements. These functions compare the binary value of elements and then produce output. There are 6 basic bitwise operations available in NumPy
1. bitwise_and()- It calculates the bit-wise AND operation between two array elements.
2. bitwise_or()- It calculates the bit-wise OR operation between two array elements.
3. invert()- It calculates the bit-wise NOT operation between two array elements.
4. bitwise_xor()- It calculates the bit-wise OR operation between two array elements.
5. left_shift()- This operator shifts the bits of the binary representation of the element towards left.
6. right_shift()- This operator shifts the bits of the binary representation of the element towards the right.
The function performs bitwise AND on two array elements. The bitwise function performs an operation on the corresponding bits of the binary representation of the operands i.e. elements. The output of the operation depends on the AND truth table. If both the corresponding values are 1 only then the output will be 1, otherwise 0. Here 1 can also is equivalent to True and 0 as False. Hence the result will be True only if both the values are True, otherwise, it will result to be False.
#numpy tutorials #numpy binary operators #numpy bitwise operators #numpy