BITLSHIFT
The 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
BITLSHIFTformula? - Examples of using
BITLSHIFTformula BITLSHIFTformula not working?- Similar formulas to
BITLSHIFT
Usage
Use the BITLSHIFT formula with the syntax shown below, it has 2 required parameters:
=BITLSHIFT(value, shift_amount)- 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.
Examples
Here are a few example use cases that explain how to use theBITLSHIFT formula 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.
Common Mistakes
BITLSHIFT not working? Here are some common mistakes people make when using the BITLSHIFT Google 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.
Related Formulas
The following functions are similar to BITLSHIFT or are often used with it in a formula:
-
BITANDThe 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.
-
BITORThe
BITORfunction returns a bitwise OR of two numbers. -
BITXORThe
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.
Learn More
You can learn more about the BITLSHIFT Google Sheets function on Google Support.