BITLSHIFTThe BITLSHIFT function shifts the bits of a given number to the left or right by a specified number of positions. This function is commonly used in engineering and computer science to perform bitwise operations on binary numbers.
- How to use
- Examples of using
BITLSHIFTformula not working?
- Similar formulas to
BITLSHIFT formula with the syntax shown below, it has 2 required parameters:
- value (required):
The number whose bits will be shifted.
- shift_amount (required):
The number of positions to shift the bits. A positive value will shift the bits to the left, while a negative value will shift the bits to the right.
ExamplesHere are a few example use cases that explain how to use the
BITLSHIFTformula in Google Sheets.
Convert binary to decimal
To convert a binary number to decimal, use the BITLSHIFT function to shift the bits to the left and then add up the resulting decimal values.
Set or clear a bit
To set or clear a specific bit in a binary number, use the BITLSHIFT function to shift a 1 to the desired position and then use a bitwise OR or AND function to combine it with the original number.
BITLSHIFTnot working? Here are some common mistakes people make when using the
BITLSHIFTGoogle Sheets Formula:
Using non-integer shift amount
The shift amount parameter must be a non-negative integer. Providing a decimal or negative number will cause an error.
Using non-numeric input value
The input value parameter must be a number. Providing a non-numeric value will cause an error.
The following functions are similar to
BITLSHIFT or are often used with it in a formula:
The BITAND function returns a bitwise AND of two numbers. This function is commonly used in engineering applications where binary digits are manipulated to perform logical operations. The function takes two inputs, value1 and value2, and returns a decimal number that represents the bitwise AND of the two inputs.
BITORfunction returns a bitwise OR of two numbers.
BITXORfunction returns the bitwise XOR of two numbers. The function takes two numeric arguments and returns the result of the bitwise XOR operation performed on them.
You can learn more about the
BITLSHIFT Google Sheets function on Google Support.