In this chapter, we will discuss about NumPy left-shift. The numpy.left_shift() function shifts the bits in the binary representation of an array element to the left by specified positions. An equal number of 0s are appended from the right.
Example Of NumPy left shift
import numpy as np print 'Left shift of 10 by two positions:' print np.left_shift(10,2) print '\n' print 'Binary representation of 10:' print np.binary_repr(10, width = 8) print '\n' print 'Binary representation of 40:' print np.binary_repr(40, width = 8) # Two bits in '00001010' are shifted to left and two 0s appended from right.
Its output is as follows −
Left shift of 10 by two positions: 40 Binary representation of 10: 00001010 Binary representation of 40: 00101000
Next Topic – Click Here
Pingback: NumPy - right shift - Adglob Infosystem Pvt Ltd % %
Pingback: NumPy Introduction - Adglob Infosystem Pvt Ltd .....
Pingback: NumPy Data Type - Adglob Infosystem Pvt Ltd .......
Pingback: NumPy Array From Numerical Ranges - Adglob Infosystem Pvt Ltd
Pingback: NumPy char add - Adglob Infosystem Pvt Ltd .........
Pingback: NumPy Binary Operators - Adglob Infosystem Pvt Ltd
Pingback: NumPy - invert - Adglob Infosystem Pvt Ltd............