BITRSHIFT
Shifts a non-negative integer right or left by a given bit count.
Positive shift_amount shifts right; negative shift_amount shifts left.
The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.
Syntax
=BITRSHIFT(number, shift_amount)
Arguments
| Argument | Type | Required | Default |
|---|---|---|---|
number | number | Required | — |
shift_amount | number | Required | — |
Remarks
numbermust be a whole number in[0, 2^48).- Shift values are numerically coerced; large right shifts return
0.
Error cases
- Negative shifts that overflow the 48-bit limit return
#NUM!.
Examples
Move the bits of 12 by two positions.
Formula =BITRSHIFT(12,2)
Expected result 3
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
A negative shift reverses the direction of the operation.
Formula =BITRSHIFT(12,-2)
Expected result 48
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
A zero-position shift leaves the bits in place.
Formula =BITRSHIFT(12,0)
Expected result 12
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Negative operands are outside the supported integer domain.
Formula =BITRSHIFT(-1,2)
Expected result #NUM!
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Shift right by three bits
Formula =BITRSHIFT(32,3)
Expected result 4
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Use negative shift to move left
Formula =BITRSHIFT(5,-1)
Expected result 10
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Related functions
FAQ
Why can negative shifts in BITRSHIFT return #NUM!?
A negative shift means left-shift; if that left result exceeds the 48-bit limit, #NUM! is returned.