Binary and data representation - EdexcelBinary shifts

All data in a computer is represented in binary, whether it is numbers, text, images or sound. The computer software processes the data according to its content.

Part ofComputer SciencePrinciples of computer science

Binary shifts

numbers are multiplied and divided through a process called shifting. There are two types of binary shift - arithmetic and logical. They work the same way for but differently for .

Multiplying and dividing binary numbers using binary shifts

Logical shift left

Logical shift left is used to multiply a positive number. To multiply a number, a binary shift moves all the digits in the binary number along to the left and fills the gaps after the shift with 0:

  • to multiply by two, all digits shift one place to the left
  • to multiply by four, all digits shift two places to the left
  • to multiply by eight, all digits shift three places to the left
  • and so on

Example: 00001100 ( 12) × 2

1286432168421
00001100
1280
640
320
160
81
41
20
10

Result: shifting one place to the left gives 00011000 (denary 24)

1286432168421
00011000
1280
640
320
161
81
40
20
10

Example: 00010110 (denary 22) × 4

1286432168421
00010110
1280
640
320
161
80
41
21
10

Result: shifting two places to the left gives 01011000 (denary 88)

1286432168421
01011000
1280
641
320
161
81
40
20
10

Logical shift right

Logical shift right is used to divide a positive number. To divide a number, a binary shift moves all the digits in the binary number along to the right and fills the gaps after the shift with 0:

  • to divide by two, all digits shift one place to the right
  • to divide by four, all digits shift two places to the right
  • to divide by eight, all digits shift three places to the right
  • and so on

Example: 00100100 (denary 36) ÷ 2

1286432168421
00100100
1280
640
321
160
80
41
20
10

Result: shifting one place to the right gives 00010010 (denary 18)

1286432168421
00010010
1280
640
320
161
80
40
21
10

Example: 00001111 (denary 15) ÷ 2

1286432168421
00001111
1280
640
320
160
81
41
21
11

Result: shifting two places to the right gives 00000111 (denary 7). Note - 15 ÷ 2 = 7.5. However, in this form of binary, there are no decimals, and so the decimal is discarded.

1286432168421
00000111
1280
640
320
160
80
41
21
11

Example: 00110110 (denary 54) ÷ 4

1286432168421
00110110
1280
640
321
161
80
41
21
10

Result: shifting two places to the right gives 00001101 (denary 13). Note – 54 ÷ 4 = 13.5. However, when the decimal is discarded, the answer is 13.’

1286432168421
00001101
1280
640
320
160
81
41
20
11