> ## Documentation Index
> Fetch the complete documentation index at: https://new.docs.falkordb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# bitwise.shiftLeft

> Shifts all bits of an integer to the left by a specified number of positions, filling vacated positions with zeros.

## 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

```cypher theme={null}
flex.bitwise.shiftLeft(a, positions)
```

## Parameters

| Parameter   | Type             | Required | Description                       |
| ----------- | ---------------- | -------- | --------------------------------- |
| `a`         | number (integer) | Yes      | The value to shift                |
| `positions` | number (integer) | Yes      | Number of positions to shift left |

## Returns

**Type:** number (integer)

The result of shifting the bits left by the specified positions.

## Examples

### Example 1: Basic Left Shift

```cypher theme={null}
RETURN flex.bitwise.shiftLeft(5, 2) AS result
```

**Output:**

```text theme={null}
result
------
20
```

(Binary: 0101 \<\< 2 = 10100 = 20)

### Example 2: Multiply by Power of Two

```cypher theme={null}
WITH 7 AS value
RETURN 
    flex.bitwise.shiftLeft(value, 1) AS times2,
    flex.bitwise.shiftLeft(value, 2) AS times4,
    flex.bitwise.shiftLeft(value, 3) AS times8
```

**Output:**

```text theme={null}
times2 | times4 | times8
-------|--------|-------
14     | 28     | 56
```

(Left shift by n is equivalent to multiplying by 2^n)

### Example 3: Creating Bit Masks

```cypher theme={null}
RETURN flex.bitwise.shiftLeft(1, 3) AS mask
```

**Output:**

```text theme={null}
mask
----
8
```

(Creates mask with bit 3 set: 1000)

## 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](/udfs/flex/bitwise/shiftRight) - Shift bits to the right
* [bitwise.and](/udfs/flex/bitwise/and) - Bitwise AND operation
* [bitwise.or](/udfs/flex/bitwise/or) - Bitwise OR operation

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="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.
  </Accordion>

  <Accordion title="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.
  </Accordion>
</AccordionGroup>
