Formualizer Docs

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

ArgumentTypeRequiredDefault
numbernumberRequired—
shift_amountnumberRequired—

Remarks

  • number must 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?.

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.

Implementation

Engine source

On this page