---
title: 3.19 Left Shift
description: "The left shift operator `"
url: "https://edcret.in/docs/c-programming/operators-and-expressions/3-19-left-shift/"
updated: "2026-09-07"
category: C Programming / Operators and Expressions
---

# 3.19 Left Shift

The left shift operator `<<` shifts the bits of an integer to the left by the specified number of positions. Bits shifted beyond the width of the type are discarded, and zero bits are introduced from the right.

```
#include <stdio.h>

int main()
{
    unsigned int number = 5;

    printf("number << 1 = %un", number << 1);
    printf("number << 2 = %un", number << 2);

    return 0;
}
```

### Example Output

```
number << 1 = 10
number << 2 = 20
```

### Explanation

The value `5` in binary is:

```
00000101
```

Shifting it left by one position:

```
00000101 << 1
00001010
```

The resulting value is `10`.

Shifting it left by two positions:

```
00000101 << 2
00010100
```

The resulting value is `20`.

For an unsigned integer, shifting a value left by `n` positions corresponds to multiplying by `2^n` when the resulting value is representable in the type. The exact result is determined by the bit representation and the width of the integer type.
