Binary Shift

Enter or generate an 8-bit number, choose a direction and how many places to shift: see every step of the working and the effect on the denary value.

8-bit binary number

= 107 decimal  |  0x6B

Shift direction

Number of places

1Working Out

Original bitZero shifted inBit shifted out (lost)
lost

27=128

bit 7

26=64

bit 6

25=32

bit 5

24=16

bit 4

23=8

bit 3

22=4

bit 2

21=2

bit 1

20=1

bit 0

Original
0
1
1
0
1
0
1
1
= 107decimal
← Shift 1
0
1
1
0
1
0
1
1
0
= 214×21 = ×2✓
← Shift 2
1
1
0
1
0
1
1
0
0
= 172×22 = ×4⚠ overflow: ‘1’ lost
← Shift 3
1
0
1
0
1
1
0
0
0
= 88×23 = ×8⚠ overflow: ‘1’ lost

Teal bits = zeros shifted in from the right.

Faded bits = bits that fell off the edge and are permanently lost.

2Summary

Original

107

01101011

×8

3 left shifts

⚠ overflow

Result

88

01011000

Mathematical working:

Left shift by 3 places = × 23 = × 8

Expected result: 107 × 8 = 856

856 > 255: does not fit in 8 bits.

8-bit result: 856 mod 256 = 88

The high-order bits that didn't fit were lost, so the result is smaller than expected. This is called overflow.

Why left shift = ×2?

Each bit position has double the place value of the one to its right (1, 2, 4, 8…). Moving every bit one place left doubles each bit's contribution, so the total doubles. Shifting left by n places multiplies by 2n.

Why right shift = ÷2?

Moving every bit one place right halves each bit's place value. The LSB is lost, so odd numbers lose the remainder (equivalent to integer/floor division). Shifting right by n places divides by 2n.