Description
Performs a left bit shift operation, moving all bits to the left by the specified number of positions. Zero bits are shifted in from the right.Syntax
Parameters
Returns
Type: number (integer) The result of shifting the bits left by the specified positions.Examples
Example 1: Basic Left Shift
Example 2: Multiply by Power of Two
Example 3: Creating Bit Masks
Notes
- Operates on 32-bit signed integers in JavaScript
- Left shift by n is equivalent to multiplying by 2^n
- Bits shifted off the left are discarded
- Zero bits are shifted in from the right
- Useful for multiplication by powers of 2 and creating bit masks
See Also
- bitwise.shiftRight - Shift bits to the right
- bitwise.and - Bitwise AND operation
- bitwise.or - Bitwise OR operation
Frequently Asked Questions
What does flex.bitwise.shiftLeft do?
What does flex.bitwise.shiftLeft do?
It shifts all bits in an integer to the left by the specified number of positions, filling vacated bits with zeros. Each left shift effectively multiplies the value by 2.
What happens if I shift by a negative number?
What happens if I shift by a negative number?
The behavior is undefined for negative shift amounts. Always use non-negative integer values for the shift count.