Overview:
-
The numpy.right_shift() function works on array-likes and scalars. It shifts the bits of the elements of one array to the corresponding element number of times to the right.
-
The effect of the shifting n bits to the right is equal to dividing the number by 2**n times.
Example:
# Example Python program that uses numpy.right_shift() # The print() function will use this for printing # Creation of ndarray # Init rightArray[0][0] = 4 # Apply right_shift() to perform division print("Left array in binary form:") |
Output:
Left array in decimal form: [[ 16 255 576]] Right array in decimal form: [[4 5 6]] Result of right_shift() in decimal form: [[1 7 9]] Left array in binary form: [['0000010000' '0011111111' '1001000000']] Right array in binary form: [['0000000100' '0000000101' '0000000110']] Result of right_shift() in binary form: [['0000000001' '0000000111' '0000001001']] |