---
title: 3.18 Left Shift Operator (<<)
description: "The left shift operator (`"
url: "https://edcret.in/docs/cpp-programming/operators-cplusplus/3-18-left-shift-operator/"
updated: "2026-07-28"
category: C++ Programming / Operators
---

# 3.18 Left Shift Operator (<<)

The left shift operator (`<<`) shifts the bits of the left operand to the left by the number of positions specified by the right operand. Each left shift moves the bits toward the more significant positions, and zeros are inserted into the vacated least significant bit positions.

For unsigned integers, shifting left by one position is generally equivalent to multiplying the value by 2, provided that no overflow occurs. Left shift operations are widely used in bit manipulation, embedded systems, and low-level programming.

## Source Code

```
#include <iostream>

int main()
{
    int number = 5;

    int result = number << 2;

    std::cout << "Original Value: " << number << '\n';
    std::cout << "Shifted Value : " << result << '\n';

    return 0;
}
```

## Output

```
Original Value: 5
Shifted Value : 20
```

## Explanation

- The left shift operator (`<<`) shifts the bits of the left operand to the left by the specified number of positions.
- `number << 2` shifts every bit of `number` two positions toward the more significant bits.
- The binary representation of `5` is:`5 = 00000101₂`
- After shifting left by two positions:`00000101₂ << 2 = 00010100₂`
- The binary value `00010100₂` is equal to the decimal value `20`.
- Vacated bit positions on the right are filled with zeros.
- For unsigned integers, shifting left by one position generally multiplies the value by 2, provided no overflow occurs.
- `return 0;` terminates the program successfully.
