In this chapter, we will discuss about NumPy invert. This function computes the bitwise NOT result on integers in the input array. For signed integers, two’s complement is returned.
Example Of NumPy invert
import numpy as np print 'Invert of 13 where dtype of ndarray is uint8:' print np.invert(np.array([13], dtype = np.uint8)) print '\n' # Comparing binary representation of 13 and 242, we find the inversion of bits print 'Binary representation of 13:' print np.binary_repr(13, width = 8) print '\n' print 'Binary representation of 242:' print np.binary_repr(242, width = 8)
Its output is as follows −
Invert of 13 where dtype of ndarray is uint8: [242] Binary representation of 13: 00001101 Binary representation of 242: 11110010
Note that the np.binary_repr() function returns the binary representation of the decimal number in the given width.
Next Topic – Click Here
Pingback: NumPy - Binary Operators - Adglob Infosystem Pvt Ltd
Pingback: NumPy - left_shift - Adglob Infosystem Pvt Ltd .........
Pingback: NumPy bitwise or - Adglob Infosystem Pvt Ltd .........