1.1 Number Systems

Question Bank · 16 Questions

Objectives: Students should be able to —

  • 1 Describe how and why computers use binary to represent data.
  • 2 Describe denary, binary and hexadecimal number systems.
  • 3 Convert numbers between denary, binary and hexadecimal.
  • 4 Describe how and why hexadecimal is used for data representation.
  • 5 Add two positive 8-bit binary numbers.
  • 6 Understand the concept of overflow when performing binary addition.
  • 7 Identify and describe uses of binary, signed (2's complement), positive, 8-bit integers.
  • 8 Convert between positive denary values into 2's complement binary number.
  • 9 Convert positive and negative denary values into 2's complement binary number.

Number Systems: Binary, Denary and Hexadecimal

Computer is made of silicon chips which contain millions of microscopic switches called transistors.

Each switch can only be in one of two states: ON (represented by 1) or OFF (represented by 0).

These ON/OFF states are processed by logic gates inside the CPU.

Therefore, all data must be converted into binary format (1s and 0s) so the computer can process, store and transmit it.

Analogue Data Digital Data
Continuous change of valuesDiscrete fixed set of values
Represented by a Sine WaveRepresented by a Square Wave
Example: human voice, temperatureExample: computer data, binary

Computers work with digital data only, so analogue data must be converted using an Analogue-to-Digital Converter (ADC).

It is a base 2 numbering system.

It uses only 2 digits: 0 and 1.

Each position represents a power of 2: …2³, 2², 2¹, 2⁰

Example: 1011 = 8 + 0 + 2 + 1 = 11₁₀

It is a base 10 numbering system.

It uses 10 digits: 0 to 9.

Each position represents a power of 10: …10³, 10², 10¹, 10⁰

Example: 345 = 300 + 40 + 5 = 345₁₀

It is a base 16 numbering system.

It uses 16 digits: 0–9 and A–F (where A = 10, B = 11, C = 12, D = 13, E = 14, F = 15).

Each position represents a power of 16: …16³, 16², 16¹, 16⁰

Note: Programmers use this numbering system as it uses very few digits to represent large binary values.

Method: Placeholders method — write the powers of 2 above each binary digit, then add the values where the bit is 1.

Example: Convert 1011011 to denary.

6432168421
1011011

Result: 64 + 0 + 16 + 8 + 0 + 2 + 1 = 91₁₀

Method: Successive division by 2 — repeatedly divide the denary number by 2 and record the remainders. Read the remainders from bottom to top.

Example: Convert denary 38 to binary.

DivisionQuotientRemainder
38 ÷ 2190
19 ÷ 291
9 ÷ 241
4 ÷ 220
2 ÷ 210
1 ÷ 201

Read remainders from bottom to top: 100110

Method: Group the binary digits into nibbles (groups of 4) starting from the right. Convert each group to its hex digit.

Example: Convert 1010 0111 1101 0101 to hexadecimal.

1010
A
0111
7
1101
D
0101
5

Result: A7D5₁₆

Method-1: Successive division by 16 — repeatedly divide by 16, record remainders, read from bottom to top.

Example: Convert denary 1453 to hex.

DivisionQuotientRemainder
1453 ÷ 169013 = D
90 ÷ 16510 = A
5 ÷ 1605

Read from bottom to top: 5AD₁₆


Method-2: Convert denary → binary → hexadecimal (group binary into nibbles, convert each to hex).

  • Hexadecimal uses very few digits to represent long binary numbers.
  • Hexadecimal numbers are easy to read, write and remember compared to long binary numbers.
  • One hex digit represents exactly 4 bits (one nibble), making conversion straightforward.
  1. To give MAC addresses for network devices (e.g. 00:1A:2B:3C:4D:5E).
  2. To give colour codes in HTML documents (e.g. #FF5733).
  3. To represent error codes generated by programs (e.g. 0x80070005).
  4. To describe memory locations in a computer.
  5. Used in assembly language coding.
  6. Used for memory dumps to trace errors in programs.
  7. Used in URL encoding to replace unsafe ASCII characters.

Addition of Binary Numbers

(a) Convert to binary:

126 = 01111110

62 = 00111110

(b) Add the two binary values:

01111110
+ 00111110
----------
10111100

Check: 126 + 62 = 188. Binary 10111100 = 128 + 32 + 16 + 8 + 4 = 188. ✓ The result matches.

01101110
+ 01101110
----------
11011100

This addition has generated a 9th bit (carry).

The 8 bits of the answer are 11011100, whose denary value is 220.

However, the correct denary sum is 110 + 110 = 220, which is within the 8-bit range (max 255).

⚠ Overflow Error: If the sum exceeds 255 (the maximum denary value of an 8-bit binary number), the result cannot be stored in 8 bits. This is known as an Overflow Error.

Logical Binary Shifts

(a) Denary value of 01001110:

64 + 8 + 4 + 2 = 78

(b) Logical shifts RIGHT (each shift divides by 2):

ShiftBinaryDenary
Original0100111078
1 right0010011139
2 right0001001119
3 right000010019
⚠ Note: 78 ÷ 2³ = 9.75, but the result is 9. The bits shifted out are lost, causing a loss of precision.

(c) Logical shifts LEFT on denary 52 (00110100):

ShiftBinaryDenary
Original0011010052
1 left01101000104
2 left11010000208
⚠ Overflow Error: Shifting further left would push bits beyond the 8-bit register, causing an overflow error because the result exceeds 255.

Two's Complement Representation of Signed Numbers

(a) Positional values for 8-bit two's complement:

-1286432168421

The MSB (Most Significant Bit) is the sign bit: 0 = positive, 1 = negative.

(b) Convert binary to denary (two's complement):

  • 10110100 → -128 + 32 + 16 + 4 = -76
  • 01100110 → 64 + 32 + 4 + 2 = 102
  • 10011100 → -128 + 16 + 8 + 4 = -100
  • 01110110 → 64 + 32 + 16 + 4 + 2 = 118

(c) Convert denary to 8-bit two's complement:

  • +4700101111
  • -5911000101
  • +8901011001

(d) Convert -45 to binary using two's complement:

Method:

  1. Convert +45 to binary: 00101101
  2. Invert all bits (flip 0 ↔ 1): 11010010
  3. Add 1: 11010011

Verification: Add +45 and -45:

00101101 (+45)
+ 11010011 (-45)
----------
00000000 (0) ✓

The carry bit is discarded, confirming the result is 0.

Step 1: Convert to 8-bit two's complement:

120 → 01111000

12 → 00001100

Step 2: Add the binary values:

01111000 (120)
+ 00001100 (12)
----------
10000100

Comment on result:

The sign bit is 1 (negative), but the expected answer is positive 132 (120 + 12).

⚠ Overflow Error has occurred because the sum (132) has exceeded the maximum positive limit of an 8-bit two's complement value, which is 127.

Revision: Statements and Key Computing Terms

Statement Key Term
The basic computing element that can be either 0 or 1.Bit
The right-most binary digit of a binary number.Least Significant Bit (LSB)
The left-most binary digit of a binary number.Most Significant Bit (MSB)
Shifting binary number 'X' places towards left.Multiplying by 2^X
Shifting binary number 'X' places towards right.Dividing by 2^X
A group of 4 bits.Nibble
A group of 8 bits.Byte
A method of representing negative numbers in binary.Two's complement
The result of a calculation that produces a value too large for the available bits.Overflow error