Excel BITRSHIFT Function changes a number into equivalent binary, shifts right by a specified number of bits, then converts back to a number.
Generic Formula
=BITRSHIFT(number,shift_amount)
Number Required. Must be a positive integer or equal to 0
Shift_amount Required. Must be an integer.
Example
Below are some examples of this function.
Figure 1 – Excel BITRSHIFT function
Explanation
The formula in C2 is =BITRSHIFT(A2,B2) returns 5 because:
- 90 is presented 1011010 in binary
- 1011010 is stripped the rightmost 4 digits and results in 101
- 101 is 5 in decimal
The return C5 is 24 because the shift_amount value is negative, which shifts bits to the left instead.
- 6 is presented 110 in binary
- 110 is stripped the leftmost by 2 digits and results in 11000
- 11000 is 24 in decimal
You can use DEC2BIN to check the binary form of the integer.
Figure 2 – Excel BITRSHIFT function
Notes:
The supplied Number must be a positive integer and smaller than (2^48)-1.
Leave a Comment