ExamYard Lectures

Logical binary shifts

IGCSE Computer Science 0478 · Chapter 1.4, Logical shifts · 6-minute lecture

The teaching part (1 min) is free to watch. A free account opens the whole lecture: 6 practice questions, 2 real past-paper questions with the answers explained, the mistakes that lose marks, the full-marks tip, a one-card summary and a quick quiz.

What this lecture covers

  1. A trick computers love
  2. What a logical shift is
  3. Left shift, one place
  4. Why it doubles
  5. Left shift, two places
Read the transcript of the teaching part

Last time

Before we start: last time, in Binary addition and overflow, you learned these points. Here they are again on one card. Keep them in mind, because today builds on them.

A trick computers love

Here is a trick computers use all the time. Take a binary number and slide every bit one place to the left. The number doubles, instantly, with no adding at all. That slide is called a logical shift.

What a logical shift is

A logical shift has three rules. Every bit moves the same number of places, left or right. Bits that move out of the register are lost. And the empty places are filled with zeros.

Left shift, one place

Here is twenty-two, 00010110. Shift it one place left. Every bit moves one column left, and a zero comes in on the right. The result is 0 0 1 0 1 1 0 0, which is forty-four. Twenty-two times two.

Why it doubles

Why does it double? Each column is worth twice the column on its right. Move every bit one column left, and every one is now worth twice as much. So the whole number doubles.

Left shift, two places

Forty-five is 00101101. Shift it two places left. Two zeros come in on the right. The answer is 1 0 1 1 0 1 0 0, which is one hundred and eighty. Two places means times two, times two: times four.

Chapter 1.4: Logical shifts

Also for IGCSE Computer Science 0478

Which topics come up most in IGCSE Computer Science 0478 past papers, counted from every paper since 2004: Paper 1 topic frequency, Paper 2 topic frequency.

The topical past-paper books: Paper 1, Paper 2.