The BITRSHIFT function in Google Sheets is a powerful tool designed to manipulate binary numbers efficiently. It performs a right bitwise shift on a specified number, moving bits to the right by a predetermined number of positions. This function is particularly useful in various mathematical and programming applications, allowing users to perform operations that are otherwise cumbersome with standard arithmetic methods.
Syntax
BITRSHIFT(value, shift_amount)
- value: The integer number whose bits you wish to shift.
- shift_amount: The number of positions to shift the bits to the right.
Example #1
=BITRSHIFT(8, 1)
This function shifts the bits of 8 (binary 1000) one position to the right, resulting in 4 (binary 0100). Example result: 4.
Example #2
=BITRSHIFT(32, 2)
In this case, 32 (binary 100000) is shifted right by 2 positions, which gives 8 (binary 001000). Example result: 8.
Example #3
=BITRSHIFT(64, 3)
Here, 64 (binary 1000000) is shifted right by 3 positions, resulting in 8 (binary 0001000). Example result: 8.
Error handling
- NUM! Indicates that the shift amount is not a valid number, which could occur if a non-numeric value is used.
- VALUE! Occurs when the input for the value or shift amount is of the wrong type, such as a text string instead of a number.