Engineering function

BITRSHIFT function

Shifts the bits of a number to the right by a given amount, which divides it by a power of 2 and drops the remainder.

Available in Excel 2013 and later, Microsoft 365, Excel for the web, Excel for Mac 2016 and later

Excel 2013 and laterWorks in Google Sheets

Syntax

BITRSHIFT(number, shift_amount)
ArgumentWhat it means
numberRequiredA whole number from 0 to 2^48 − 1.
shift_amountRequiredHow many positions to move the bits to the right. A negative value shifts left instead. Must be between -53 and 53.

Returns: A decimal number: number divided by 2^shift_amount, rounded down.

How BITRSHIFT works

BITRSHIFT moves every bit of a number to the right; the bits that fall off the end are thrown away. Shifting right by k places is the same as dividing by 2^k and discarding the remainder, so BITRSHIFT(13, 2) is INT(13/4) = 3.

Its most common job is unpacking values that were stored together. A colour in Excel's Color property, for example, holds blue in the top byte, green in the middle byte and red in the bottom byte; shift right by 8 and mask with BITAND 255 to pull out the green value. A negative shift_amount shifts left like BITLSHIFT. Inputs must be whole numbers from 0 to 2^48 − 1.

Examples

1Shift right by 2

C2fx=BITRSHIFT(A2, B2)
ABC
1NumberShift
21323

Result: 3

13 is 1101. Moving it two places right drops the last two bits (01) and leaves 11, which is 3.

2Extract the green value from a colour number

B2fx=BITAND(BITRSHIFT(A2, 8), 255)
AB
1Colour value
216748574144

Result: 144

16748574 is the colour number Excel stores for RGB(30, 144, 255) (red + green×256 + blue×65536). Shifting right 8 bits removes the red byte; BITAND with 255 then keeps only the green byte: 144.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 13 KB

Common errors and how to fix them

ErrorWhy it happensFix
#NUM!The number is negative, not whole, at least 2^48, or |shift_amount| is more than 53.Use whole numbers in range; use INT with division for larger values.
#VALUE!An argument is non-numeric text.Convert with VALUE.

Tips

  • BITRSHIFT(n, k) gives the same answer as INT(n/2^k) for valid inputs.
  • Combine shift and mask to read any field: =BITAND(BITRSHIFT(value, start_bit), 2^width-1).

Google Sheets

BITRSHIFT also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

BITRSHIFT in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
DanishBITRSKIFT
DutchBIT.VERSCHUIF.RECHTS
FinnishBITTI.SIIRTO.O
FrenchBITDECALD
GermanBITRVERSCHIEB
HungarianBIT.JOBB.ELTOL
ItalianBIT.SPOSTA.DX
Norwegian (Bokmål)BITHFORSKYV
PolishBIT.PRZESUNIĘCIE.W.PRAWO
Portuguese (Brazil)DESLOCDIRBIT
Portuguese (Portugal)BITDESL.DIR
RussianБИТ.СДВИГП
SpanishBIT.DESPLDCHA
SwedishBITHSKIFT
TurkishBİTSAĞAKAYDIR