The BITLSHIFT function in Google Sheets is a powerful tool for bit manipulation, enabling users to shift the binary representation of a number to the left by a specified number of positions. This function is particularly useful in scenarios involving low-level data processing or calculations that depend on binary arithmetic.
Syntax
BITLSHIFT(value, shift_amount)
- value: The integer input that you want to shift. This is the numeric value in its binary form.
- shift_amount: The number of positions to shift the binary representation of the value to the left. This is often a positive integer.
Example #1
=BITLSHIFT(4, 2)
This function takes the number 4, which in binary is 0100, and shifts it two positions to the left. The result is 16, as the binary representation becomes 10000.
Example #2
=BITLSHIFT(3, 1)
By shifting the number 3, represented in binary as 0011, one position to the left, the output is 6, since the binary form changes to 0110.
Example #3
=BITLSHIFT(7, 3)
This function call shifts the binary representation of 7 (which is 0111) three positions to the left, producing the result 56, with the new binary form being 111000.
Error handling
- NUM! This error occurs if “shift_amount” is a negative number or exceeds the range of bit shifts allowable for the data type.
- VALUE! This error arises if “value” is not a valid integer, indicating that the input is not suitable for bit manipulation.