Home Notes Papers

Number systems

Paper 1Paper 2

This section is examined in Paper 1 and Paper 2.

Why Computers Use Binary (LO1)
Computers use binary (base-2) to represent all data because of their physical hardware design. Computer processors are made of billions of tiny electronic switches called transistors. Each transistor can exist in one of two stable states: ON or OFF.

This maps perfectly to the binary digits:

  • ON = 1
  • OFF = 0

Using binary is beneficial because it is reliable and simple. Electronic circuits only need to distinguish between two voltage levels (e.g., high voltage for 1, low voltage for 0). This reduces the chance of errors compared to trying to distinguish between 10 different voltage levels (which would be required for denary/base-10).

Building on this, all forms of data—text, images, sound, and video—are converted into binary sequences before the computer can process them. This is not because computers 'understand' binary in a linguistic sense, but because their hardware physically operates using binary logic gates.

Number Systems (LO2)
A number system is defined by its base (or radix), which determines how many unique digits are used and the value of each position.

System Base Digits Used Description
Denary (Decimal) 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 The standard system humans use. Position values are powers of 10 (10^0, 10^1, 10^2...).
Binary (Base-2) 2 0, 1 Used by computers. Position values are powers of 2 (2^0, 2^1, 2^2...).
Hexadecimal (Hex) 16 0-9, A-F Used by programmers. Digits A to F represent denary values 10 to 15. Position values are powers of 16 (16^0, 16^1, 16^2...).

Note on Hexadecimal Digits:

  • A = 10
  • B = 11
  • C = 12
  • D = 13
  • E = 14
  • F = 15

This relates to binary because one hexadecimal digit represents exactly four binary digits (a nibble). This makes Hex a compact shorthand for long binary strings.

Converting Positive Denary to Positive Binary (LO3)
To convert a positive denary number to binary, use the powers of 2 method. Write out the powers of 2 from right to left (1, 2, 4, 8, 16, 32, 64, 128...) until you exceed your target number.

Example: Convert Denary 19 to Binary

Power of 2 128 64 32 16 8 4 2 1
Bit 0 0 0 1 0 0 1 1

Reasoning:

  • Does 19 fit in 128? No (0).
  • Does 19 fit in 64? No (0).
  • Does 19 fit in 32? No (0).
  • Does 19 fit in 16? Yes. Subtract 16 from 19, remainder is 3. (Bit = 1)
  • Does 3 fit in 8? No (0).
  • Does 3 fit in 4? No (0).
  • Does 3 fit in 2? Yes. Subtract 2 from 3, remainder is 1. (Bit = 1)
  • Does 1 fit in 1? Yes. Remainder is 0. (Bit = 1)

Result: 00010011_2

Examiner Tip: Always write the bits in the correct column order. A common mistake is writing the binary string backwards or skipping columns.

⚠︎ Denary to Hexadecimal Conversion Errors (LO4)
The Error: Students often convert Denary to Binary first, then try to convert that binary string to Hexadecimal, but they make errors in the nibble grouping or hex digit mapping.

The Correct Understanding: You can convert Denary to Hex directly by repeated division by 16, which is often faster and less prone to transcription errors than going through binary.

Example: Convert Denary 267 to Hexadecimal

  1. 267 \div 16 = 16 remainder 11 (which is B)
  2. 16 \div 16 = 1 remainder 0
  3. 1 \div 16 = 0 remainder 1

Read the remainders from bottom to top: 10B_{16}.

Why this matters: If you convert via binary (267 = 100001011_2), you must pad with leading zeros to make groups of 4: 0001\ 0000\ 1011. Then 1=1, 0=0, 11=B. Both methods yield 10B, but the division method is more direct.

Benefits of Hexadecimal (LO6)
Context: When asked to explain why hexadecimal is used in computing.

Correct Phrasing: "Hexadecimal provides a shorter, more human-readable representation of binary data."

Reasoning: Examiners accept this because it addresses the practical utility for programmers. A 32-bit memory address like 11110000111100001111000011110000_2 is difficult to read and prone to transcription errors. In Hex, this is F0F0F0F0_{16}, which is much easier to debug and verify.

Example Usage: "Programmers use hexadecimal because it takes up less screen space and is easier for humans to spot errors compared to long strings of binary digits."

Binary Addition (LO7)
Q:
Add the two positive 8-bit binary integers: 01100101_2 + 01110000_2. Show your working.
A:

Working:

Carry 1 1 1 1
Bit 1 0 1 1 0 0 1 0 1
Bit 2 0 1 1 1 0 0 0 0
Sum 1 0 0 1 0 1 0 1

Result: 11010101_2

Mark Scheme Key Points:

  • Correct application of binary addition rules (1+1=10_2, i.e., write 0 carry 1).
  • Final answer 11010101_2.
Overflow in Binary Addition (LO8)
Overflow occurs when the result of a binary arithmetic operation is too large to be represented within the fixed number of bits allocated.

In 8-bit signed integers (using two's complement), the range is -128 to +127. If you add two positive numbers and the result exceeds 127, or add two negative numbers and the result is less than -128, overflow has occurred.

How to detect it visually:

  1. Look at the Most Significant Bit (MSB) (the leftmost bit). In signed binary, the MSB indicates the sign (0 for positive, 1 for negative).
  2. If you add two positive numbers (both start with 0) and the result starts with 1, overflow has occurred.
  3. Alternatively, if you add two negative numbers (both start with 1) and the result starts with 0, overflow has occurred.

Example:
Add +100 (01100100_2) and +50 (00110010_2).
Sum = 10010110_2. The MSB is 1, indicating a negative number. Since we added two positives, the result should be positive. The overflow bit (carry out of the MSB) is often ignored in simple signed arithmetic checks, but the sign error confirms overflow.

Logical Binary Shifts (LO9)

A logical shift moves all bits in a binary integer to the left or right. Zeros are shifted in from the opposite side.

Shift Type Direction Effect on Positive Integer Note
Logical Left Shift Left (\ll) Multiplies the value by 2^n (where n is the number of shifts). Bits shifted out of the MSB are lost. If a 1 is shifted out, the magnitude changes significantly.
Logical Right Shift Right (\gg) Divides the value by 2^n (integer division, discarding remainder). Bits shifted out of the LSB are lost. This reduces precision.

Constraint for Positive Integers:
For a positive 8-bit integer, the MSB is always 0.

  • A left shift is safe as long as the new MSB remains 0 (i.e., no overflow into the sign bit). If the MSB becomes 1, the number is interpreted as negative in two's complement.
  • A right shift preserves the positive sign (MSB stays 0) but loses data from the right.
Two's Complement for Positive and Negative Integers (LO10)
Two's complement is the standard method for representing signed integers in binary. The Most Significant Bit (MSB) indicates the sign:

  • 0 = Positive
  • 1 = Negative

Representing a POSITIVE Integer:
To represent a positive integer, simply convert it to binary and pad with leading zeros so the MSB is 0. It looks identical to unsigned binary.

Example: Represent +5 in 8-bit two's complement.

  1. Denary 5 in binary is 101_2.
  2. Pad to 8 bits: 00000101_2.
  3. Check MSB: It is 0, so it is positive. Correct.

Representing a NEGATIVE Integer:
To represent -N, take the binary of +N, invert all bits (flip 0s to 1s and 1s to 0s), then add 1.

Example: Represent -22 in 8-bit two's complement.

  1. Denary 22 in binary: 00010110_2.
  2. Invert bits: 11101001_2.
  3. Add 1: 11101001 + 1 = 11101010_2.
  4. Check MSB: It is 1, so it is negative. Correct.

Why this works: The MSB in two's complement has a negative weight. In an 8-bit number, the weights are:
-128, +64, +32, +16, +8, +4, +2, +1.
For 11101010_2: -128 + 64 + 32 + 16 + 0 + 4 + 0 + 0 = -128 + 116 = -12. Wait, let's re-calculate.
-128 + 64 + 32 + 16 + 4 + 2 = -128 + 118 = -10? No.
Let's check -22 again.
+22 = 00010110.
Flip: 11101001.
Add 1: 11101010.
Value: -128 + 64 + 32 + 16 + 0 + 4 + 0 + 0 = -128 + 116 = -12.
Correction: My manual calculation in the example step was wrong. Let's re-verify +22.
16 + 4 + 2 = 22. Correct.
Flip: 11101001.
Add 1: 11101010.
Sum of positive weights: 64+32+16+4+2 = 118.
-128 + 118 = -10.
Wait, where is the error?
Ah, 22 = 16 + 4 + 2. Binary: 00010110.
Flip: 11101001.
Add 1: 11101010.
Weights: -128, 64, 32, 16, 8, 4, 2, 1.
Bits: 1, 1, 1, 0, 1, 0, 1, 0.
Sum: -128 + 64 + 32 + 0 + 8 + 0 + 2 + 0 = -128 + 106 = -22.
Correct. The bit at position 8 (value 8) is 1. In my previous line I wrote 0 for that position. The binary is 11101010. Positions: 7(-128), 6(64), 5(32), 4(16), 3(8), 2(4), 1(2), 0(1).
Bits: 1, 1, 1, 0, 1, 0, 1, 0.
-128 + 64 + 32 + 8 + 2 = -128 + 106 = -22. Correct.

⚠︎ Two's Complement MSB Weight Error (LO10)
The Error: Students often treat the MSB in two's complement as a positive value (+128) when converting back to denary, or they simply add a 1 to the front of the binary number without flipping.

The Correct Understanding: In 8-bit two's complement, the MSB has a weight of -128, not +128.

If you are given a negative two's complement number like 11101010_2, you must calculate:
(-1 \times 128) + (1 \times 64) + (1 \times 32) + (0 \times 16) + (1 \times 8) + (0 \times 4) + (1 \times 2) + (0 \times 1).

Common Mistake: Converting -22 by taking binary 22 (00010110) and just changing the first bit to 1 (10010110). This is incorrect. You must invert all bits then add 1.

Hexadecimal Conversion Strategy (LO5)
Context: When asked to convert between Hex and Binary.

Correct Phrasing: "Each hexadecimal digit corresponds to a 4-bit nibble."

Reasoning: Examiners look for the direct mapping relationship. You do not need to go through denary.

  • F_{16} = 1111_2
  • A_{16} = 1010_2
  • 0_{16} = 0000_2

Example Usage: "To convert Hex to Binary, replace each hex digit with its 4-bit binary equivalent. To convert Binary to Hex, group the bits into sets of four starting from the right, then convert each nibble to its hex digit."

Logical Shift Effect (LO9)
Q:
State the effect of a logical left shift by 2 positions on the positive binary integer 00101100_2. Give the result in binary and denary.
A:
Binary Result:
Original: 00101100_2 (44_{10})
Shift Left 1: 01011000_2 (88_{10})
Shift Left 2: 10110000_2

Denary Result:
10110000_2 = 128 + 32 + 16 = 176_{10}.

Effect Explanation: The value has been multiplied by 4 (2^2). 44 \times 4 = 176.

Note: In this specific case, the MSB became 1, which would make it a negative number in two's complement signed arithmetic. However, as a positive unsigned integer or logical shift, the magnitude is simply multiplied by 2^n.

Beta v0.7.8 Free while we're in beta — it transitions to paid post launch. Thank you for supporting us at this stage!