4.3 Bit manipulation

2026 Syllabus Objectives

By the end of this topic, you should be able to:

  • understand and perform binary shifts
  • understand logical shifts, arithmetic shifts and cyclic shifts
  • understand both left shifts and right shifts
  • understand how bit manipulation can be used to monitor and control a device
  • carry out bit manipulation operations
  • test and set a bit using bit masking
  • recognise the use of instructions such as AND, OR, XOR, LSL and LSR

What is bit manipulation?

Bit manipulation means changing, testing, or moving individual bits inside a binary number.

A bit is a single binary digit. It can only be 0 or 1.

In this topic, you need to understand two main uses of bit manipulation:

  1. shifting bits left or right
  2. using bitwise operations to test or change bits when controlling devices

This is important because computers and embedded systems often store information as groups of bits. Each bit can represent something small, such as whether a switch is ON or OFF, whether a sensor has been triggered, or whether a warning light should appear.


Binary shifts

A binary shift moves all bits in a binary value to the left or to the right.

There are three shift types in this syllabus:

  • logical
  • arithmetic
  • cyclic

You must also know the difference between left shift and right shift.


A logical shift moves bits left or right and fills any empty space with 0.

Logical shifts are mainly used for:

  • unsigned binary numbers
  • general bit manipulation where the bits are treated just as patterns

Logical left shift

In a logical left shift, every bit moves one or more places to the left. New spaces on the right are filled with 0.

Look at this 8-bit value:

00001110

This is denary 14.

Now shift it left by 2 places:

  • original: 00001110
  • after 1 left shift: 00011100
  • after 2 left shifts: 00111000

The result is 00111000, which is denary 56.

A logical left shift by 1 usually multiplies the number by 2. A logical left shift by 2 usually multiplies the number by 4.

So here:

  • 14 × 2 = 28
  • 28 × 2 = 56

That matches the shifted result.

Important idea

A left shift can be a quick way to multiply by powers of 2.

But this only works properly when no important bits are lost off the left side. If bits move out of the byte, the value may no longer be correct.

Sign in to view full notes