📚 Knowledge Library — Topic 1 — Data Representation

Binary Manipulation and Negative Numbers

Learn how computers shift binary values, add binary numbers, detect overflow, and represent negative integers using two's complement.

1. Invitation

Computers do not just store binary — they change it.

In the previous lesson, binary was used to represent values. In this lesson, those values start moving, combining and changing.

Binary manipulation includes logical shifts, binary addition, overflow and two's complement. These are small rules, but they sit behind real processor arithmetic.

💡 Remember: binary manipulation is not a new topic. It is binary being moved, added or reinterpreted.
Figure 1.1
Binary can be manipulated
SHIFT
ADD
CHECK OVERFLOW
REPRESENT NEGATIVES
2. Logical Shifts

A logical shift moves every bit left or right.

In a logical shift, every bit moves by a set number of places. Empty spaces are filled with 0s.

A left shift usually multiplies the value by powers of 2. A right shift usually divides the value by powers of 2.

Logical left shift by 2 places

0
0
1
1
0
1
1
0
00110110 → 11011000
🎯 Exam Tip: left shift by 1 = ×2, left shift by 2 = ×4, left shift by 3 = ×8.
Figure 2.1
Logical Left Shift
00110110
⇐ ⇐
11011000
Zeros fill the empty spaces on the right.
3. Right Shifts

A right shift divides by powers of 2.

A logical right shift moves bits towards the right. Empty spaces on the left are filled with 0s.

Bits that fall off the right-hand side are lost. This is why students must be careful when copying the final 8-bit answer.

Logical right shift by 3 places

1
1
1
0
0
0
1
0
11100010 → 00011100
⚠️ Common Mistake: do not fill empty spaces with 1s. Logical shifts fill empty spaces with 0s.
Figure 3.1
Logical Right Shift
11100010
⇒ ⇒ ⇒
00011100
Zeros fill the empty spaces on the left.
4. Binary Addition

Binary addition uses four simple rules.

Binary addition works from right to left, just like denary addition. The difference is that each column can only contain 0 or 1.

When a column becomes too large, a carry is passed to the next column.

RuleResult
0 + 00
0 + 11
1 + 110
1 + 1 + 111
🎯 Exam Tip: Cambridge expects binary addition working to show the carry bits. Converting to denary and back does not show binary addition.
Figure 4.1
Carry the 1
1 + 1 = 10

write 0
carry 1
5. Overflow

Overflow happens when the answer is too large.

An 8-bit register can only store 8 bits. If binary addition produces a 9-bit answer, the extra bit cannot fit.

This is called overflow. The stored result becomes incorrect because the extra carry bit is lost.

Overflow example

11110000
+ 10100011
────────
1 10010011
The leftmost carry creates a 9-bit result.
💡 Overflow means the result is too large to fit in the available number of bits.
Figure 5.1
Too many bits
8-bit space

10010011

+
extra carry lost
6. Two's Complement

Two's complement represents negative numbers.

Binary has no minus sign. To store negative integers, computers use a method called two's complement.

The recipe is simple: write the positive binary value, invert every bit, then add 1.

Convert -12 to 8-bit two's complement

12 = 00001100
invert = 11110011
add 1 = 11110100
-12 = 11110100
💡 Two's complement recipe: convert positive value → invert bits → add 1.
Figure 6.1
The Mirror and the Nudge
00001100

11110011
+1
11110100
7. Converting Back to Denary

The most significant bit tells you the sign.

In 8-bit two's complement, if the most significant bit is 0, the number is positive. If it is 1, the number is negative.

For negative values, you can invert all bits and add 1 to find the size of the number, then add the minus sign.

Convert 11110110 to denary

MSB = 1 → negative
invert = 00001001
add 1 = 00001010 = 10
Answer = -10
⚠️ Common Mistake: do not forget the minus sign in the final answer.
Figure 7.1
8-bit Two's Complement Range
-128
to
+127
The MSB acts as the sign bit.
8. Exam Focus

These marks are won through method.

This topic rewards clear working. For shifts, show the direction and the zeros added. For addition, show carries. For two's complement, show each stage.

The most common mistakes are not mathematical difficulty — they are method mistakes.

🎯 Exam Tip: write the method even when the final answer seems obvious. Working can earn marks even if the final answer contains an error.
⚠️ Common Mistakes: shifting the wrong direction, filling gaps with 1s, using sign-and-magnitude, and treating the MSB as +128 instead of part of a negative value.
Figure 8.1
Show the method
SHIFT → direction
ADD → carries
NEGATIVE → invert + 1
OVERFLOW → too many bits