Microsoft Excel Bitshift in formula
By Emma Valentine •
Is it possible to bit-shift a number in a formula in Microsoft Excel?
I want to do something equivalent to
=(a1<<2)I know I could just divide/multiply by a power of 2 and round, but this would be simpler.
UPDATE: I am using Excel 2010 so I do not have access to BITLSHIFT.
3 Answers
I don't know the correct syntax but there is a BITLSHIFT and a BITRSHIFT function in Excel.
You can see more about it here
1E2: =BIN2DEC(RIGHT(TEXT(DEC2BIN(A2),0)&REPT("0",B2),C2))
E3: =RIGHT(MID(A3,3,LEN(A3))&REPT(0,B3),C3)
F2: =BIN2DEC(REPT("0",B2)&MID(DEC2BIN(A2,8),1,LEN(DEC2BIN(A2,8))-B2))
F3: =REPT(0,B3)&MID(A3,1,LEN(A3)-B3)
we can do the following simple math:
= BINRSHIFT(number, shift_value)is equivalent to
= number/(2^shift_value)Similarly,
=BINLSHIFT(number, shift_value)is equivalent to
= number*(2^shift_value)