# Bitwise Shift Left

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: Bitwise Shift Left
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: sql/sql-operators/bitwise-shift-left
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-operators/bitwise-shift-left.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-operators/bitwise-shift-left.adoc
description: Bitwise shift operators in Redpanda SQL manipulate the bits of integer value by shifting them left or right.
page-topic-type: reference
page-git-created-date: "2026-05-26"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-operators/bitwise-shift-left.md -->

Bitwise shift operators in Redpanda SQL manipulate the bits of integer value by shifting them left or right. These operations are fundamental in low-level data processing and optimization.

The bitwise **left shift (`<<`)** operator shifts the bits of an integer to the left by the specified shift amount. For **integers**, this operation is equivalent to multiplying the integer value by 2 raised to the power of the shift amount. During this operation, high-order bits that are shifted out are permanently lost without the ability to be preserved, while zeros are shifted in from the right to fill the vacant positions. Because the left shifts operation (<<) on signed integers is **arithmetic**, meaning it shifts all bits to the left and fills the vacant rightmost bits with zeros on the right, the behavior is the same as a logical shift in this case. However, the overall length of the bit string is preserved, with zeros padding on the right to maintain the length.

## [](#syntax)Syntax

The syntax for this function is:

```sql
value << shift_amount
```

## [](#parameters)Parameters

-   `value`: Integer expression.

-   `shift_amount`: A **non-negative** integer specifying how many bit positions to shift.


## [](#restrictions)Restrictions

Bitwise shift operators in Redpanda SQL require the shift amount to be a **non-negative** integer. Redpanda SQL treats negative shift counts as valid by applying modulo arithmetic based on the bit width, so shifting `1 << -3` in a 32-bit integer is equivalent to shifting `1 << 29`, producing predictable results without errors or undefined behavior.

When performing bitwise left shift operations (<<) on 32-bit integer values in Redpanda SQL, the shift count is taken **modulo** 32. This means: \* Shifting by a number of bits greater than or equal to 32 wraps around \* For example, `1 << 35` is equivalent to `1 << 3` because `35`\\(modulo\\)`32 = 3`

> ⚠️ **WARNING**
>
> If you shift by a value larger than or equal to 32, the actual shift is the remainder after dividing by 32, which may lead to unexpected results if not carefully considered.

## [](#examples)Examples

This section uses a simplified version of the `film` table from the Pagila database, containing only the `title`, `rating` and `privilegs` columns. The complete schema for the `film` table can be found on the [Pagila](https://www.postgresql.org/ftp/projects/pgFoundry/dbsamples/pagila/pagila/) database website.

```sql
DROP TABLE IF EXISTS film;
CREATE TABLE film (
  title TEXT NOT NULL,
  rating TEXT,
  privileges INT NOT NULL
);
INSERT INTO film(title, rating, privileges) VALUES
  ('ATTRACTION NEWTON', 'PG-13', 1),     -- Free users
  ('CHRISTMAS MOONSHINE', 'NC-17', 2),   -- Premium users
  ('DANGEROUS UPTOWN', 'PG', 3),         -- Free + Premium users (bits 0 and 1)
  ('KILL BROTHERHOOD', 'G', 4),          -- Admin-only content
  ('HALLOWEEN NUTS', 'PG-13', 1),
  ('HOURS RAGE', 'NC-17', 2),
  ('PIANIST OUTFIELD', 'NC-17', 3),
  ('PICKUP DRIVING', 'G', 4),
  ('INDEPENDENCE HOTEL', 'NC-17', 1),
  ('PRIVATE DROP', 'PG', 2),
  ('SAINTS BRIDE', 'G', 3),
  ('FOREVER CANDIDATE', 'NC-17', 4),
  ('MILLION ACE', 'PG-13', 1),
  ('SLEEPY JAPANESE', 'PG', 2),
  ('WRATH MILE', 'NC-17', 3),
  ('YOUTH KICK', 'NC-17', 4),
  ('CLOCKWORK PARADISE', 'PG-13', 1);
```

> 📝 **NOTE**
>
> -   Privilege 1 (binary 0001): Free users can watch.
>
> -   Privilege 2 (binary 0010): Premium users can watch.
>
> -   Privilege 3 (binary 0011): Both free and premium users can watch.
>
> -   Privilege 4 (binary 0100): Admin-only content.

The following query uses the integer `Left shift (<<)` operation, shifting the privileges value left by 1 for the movie ‘ATTRACTION NEWTON’:

```sql
UPDATE film
SET privileges = privileges << 1
WHERE title = 'ATTRACTION NEWTON';
```

After running the update, you can verify the change with:

```sql
SELECT title, privileges FROM film WHERE title = 'ATTRACTION NEWTON';
```

Expected output:

```sql
       title       | privileges
-------------------+------------
 ATTRACTION NEWTON |          2
(1 row)
```