Singapore O-Level / G3 Computing
Two’s Complement, Binary and Hexadecimal for O-Level / G3 Computing
Two’s complement is the method computers use to store negative whole numbers in binary: the leftmost bit has a negative place value, so in 8 bits it is worth -128 and the range is -128 to 127. It sits in Module 1.2 Data Representation of G3 Computing (Syllabus K349), with binary, denary and hexadecimal conversion and 8-bit extended ASCII.
This guide covers every Module 1.2 learning outcome with full working, plus the storage unit calculations from Module 1.1. Finish with the exam-style questions.
Two’s complement and number systems at a glance
- Syllabus section: Module 1.2 Data Representation, learning outcomes 1.2.1 to 1.2.4
- Number systems: binary (base 2), denary (base 10) and hexadecimal (base 16)
- Two’s complement in 8 bits: leftmost bit worth -128, range -128 to 127
- Hex shortcut: one hex digit equals one 4-bit nibble
- Text: 8-bit extended ASCII stores each character in one byte
- Tested in: Paper 1, the written paper
On this page
- What Module 1.2 Data Representation asks you to do
- Binary place values and denary to binary conversion
- Binary to hexadecimal, hex to binary and denary to hex
- Two’s complement: negative numbers in 8 bits
- 8-bit extended ASCII: how text is stored as bits
- Storage unit calculations (Module 1.1)
- Exam-style practice questions with worked answers
- Common mistakes in binary, hex and two’s complement
- Frequently asked questions
What Module 1.2 Data Representation asks you to do
Module 1.2 in G3 Computing (Syllabus K349) has four learning outcomes:
- 1.2.1: represent positive whole numbers in binary.
- 1.2.2: convert positive whole numbers between binary, denary and hexadecimal, and describe the technique used.
- 1.2.3: use two’s complement for a fixed number of bits to represent positive and negative whole numbers.
- 1.2.4: use 8-bit extended ASCII for English text to explain how information is represented as bits.
Describe the technique used means you may have to explain your method in words, so practise saying the steps aloud. Binary addition and overflow do not appear in the Module 1.2 list, so this guide leaves them out. For the other modules, read our full G3 Computing syllabus guide.
Binary place values and denary to binary conversion
Binary is base 2. Each bit is worth double the bit to its right, so the 8-bit place values are 128, 64, 32, 16, 8, 4, 2 and 1. The largest 8-bit positive value is 255.
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| 77 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 |
77 = 64 + 8 + 4 + 1, so 77 = 01001101.
Denary to binary: subtract place values
Take the largest place value that fits, write 1, subtract and move right. Write 0 where a place value is too big. For 156: 156 – 128 = 28, 28 – 16 = 12, 12 – 8 = 4, 4 – 4 = 0. The bits for 128, 16, 8 and 4 are 1, so 156 = 10011100.
Denary to binary: divide by 2
Divide by 2 until the quotient is 0, then read the remainders from the bottom up.
156 ÷ 2 = 78 r 0 78 ÷ 2 = 39 r 0 39 ÷ 2 = 19 r 1 19 ÷ 2 = 9 r 1 9 ÷ 2 = 4 r 1 4 ÷ 2 = 2 r 0 2 ÷ 2 = 1 r 0 1 ÷ 2 = 0 r 1
Reading upwards gives 10011100 again.
Binary to denary
Add the place values that have a 1. For 10110101: 128 + 32 + 16 + 4 + 1 = 181. For more drills, see our short post on binary to denary conversion.
Binary to hexadecimal, hex to binary and denary to hex
Hexadecimal is base 16. It uses 0 to 9, then A to F for 10 to 15. One hex digit stands for exactly four bits, called a nibble, which makes hex a compact way to write binary.
| Hex | Denary | Nibble |
|---|---|---|
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
Binary to hex
Split the bits into groups of four from the right, pad the leftmost group with zeros, and convert each group. 10110101 becomes 1011 0101, which is B5. 101101 becomes 0010 1101, which is 2D.
Hex to binary
Replace each digit with its 4-bit nibble. 3E becomes 0011 1110, so 3E = 00111110. Always write all four bits per digit.
Hex to denary
The two place values are 16 and 1. 2F = (2 × 16) + 15 = 47. B5 = (11 × 16) + 5 = 181, matching the binary example above.
Denary to hex
Divide by 16. The quotient gives the left digit and the remainder the right digit. 200 ÷ 16 = 12 remainder 8, and 12 is C, so 200 = C8. You can also go through binary: 200 = 11001000 = 1100 1000 = C8.
Two’s complement: negative numbers in 8 bits
In two’s complement the leftmost bit, the most significant bit, has a negative place value. In 8 bits it is worth -128 and the other seven bits keep their usual values.
| Value | -128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| 127 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| -45 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 1 |
| -128 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
- A leading 0 means zero or positive, read exactly like ordinary binary.
- A leading 1 means negative.
- The range is -128 (10000000) to 127 (01111111): 256 values.
Method 1: invert and add 1
To write -45:
- Write +45 in 8 bits: 00101101.
- Invert every bit: 11010010.
- Add 1:
11010011.
Method 2: negative place value
-45 = -128 + 83, and 83 = 64 + 16 + 2 + 1. Set the -128 bit and those four bits to get 11010011. Use one method to check the other.
Two’s complement to denary
For 10110110:
- Place values: -128 + 32 + 16 + 4 + 2 = -74.
- Invert and add 1: the leading 1 means negative. Invert to 01001001, add 1 to get 01001010 = 74, so the value is -74.
Other bit widths
With n bits the range is -2^(n-1) to 2^(n-1) - 1. In 4 bits that is -8 to 7. The methods stay the same.
8-bit extended ASCII: how text is stored as bits
ASCII gives every character a number code. In 8-bit extended ASCII each character takes one byte, giving 256 codes from 0 to 255. Codes 0 to 127 are standard ASCII: English letters, digits, punctuation and control codes. Codes 128 to 255 add extra symbols and accented letters.
| Character | Denary | Binary | Hex |
|---|---|---|---|
| A | 65 | 01000001 | 41 |
| a | 97 | 01100001 | 61 |
| 0 (digit) | 48 | 00110000 | 30 |
Capitals run in order from 65 and small letters from 97, so each small letter is 32 more than its capital. The character 7 has code 55, which differs from the number 7.
The word Cat in 8-bit extended ASCII:
C = 67 = 01000011 a = 97 = 01100001 t = 116 = 01110100
Cat takes 3 bytes, or 24 bits. In Python, ord('A') returns 65 and chr(97) returns ‘a’, which covers learning outcome 2.3.8.
Storage unit calculations (Module 1.1)
Learning outcome 1.1.1 asks for calculations with bits, bytes and every unit up to petabytes and pebibytes. One byte is 8 bits. Decimal units step by 1,000. Binary units, the ones with bi in the name, step by 1,024.
| Decimal unit | Bytes | Binary unit | Bytes |
|---|---|---|---|
| kilobyte (kB) | 1,000 | kibibyte (KiB) | 1,024 |
| megabyte (MB) | 1000^2 | mebibyte (MiB) | 1024^2 = 1,048,576 |
| gigabyte (GB) | 1000^3 | gibibyte (GiB) | 1024^3 |
| terabyte (TB) | 1000^4 | tebibyte (TiB) | 1024^4 |
| petabyte (PB) | 1000^5 | pebibyte (PiB) | 1024^5 |
Divide to move to a larger unit and multiply to move to a smaller one. For example, 3 MiB = 3 × 1,048,576 = 3,145,728 bytes.
Exam-style practice questions with worked answers
Question 1
Convert 11101010 to hexadecimal and to denary.
Answer: 1110 1010 is E and A, so EA. Denary: 128 + 64 + 32 + 8 + 2 = 234. Check: (14 × 16) + 10 = 234.
Question 2
Represent -100 in 8-bit two’s complement.
Answer: +100 = 64 + 32 + 4 = 01100100. Invert: 10011011. Add 1: 10011100. Check: -128 + 16 + 8 + 4 = -100.
Question 3
What denary value does the 8-bit two’s complement number 11111000 represent?
Answer: -128 + 64 + 32 + 16 + 8 = -8. Check: invert to 00000111, add 1 to get 00001000 = 8.
Question 4
State the range of 8-bit two’s complement. Can +150 be stored?
Answer: -128 to 127. 150 is above 127, so no. The pattern 10010110 would be read as -128 + 16 + 4 + 2 = -106. At least 9 bits are needed.
Question 5
Describe the technique to convert denary 200 to hexadecimal.
Answer: Divide 200 by 16, giving quotient 12 and remainder 8. Convert each to a hex digit: 12 is C, 8 is 8. Write the quotient digit then the remainder digit: C8. Check: (12 × 16) + 8 = 200.
Question 6
The ASCII code for A is 65. Give the 8-bit binary code for D.
Answer: D = 65 + 3 = 68 = 64 + 4, so 01000100.
Question 7
A file holds 2,000 characters in 8-bit extended ASCII. Give its size in bits, kB and KiB.
Answer: 2,000 bytes. Bits: 2,000 × 8 = 16,000. kB: 2,000 ÷ 1,000 = 2. KiB: 2,000 ÷ 1,024 = 1.953125, about 1.95 KiB.
Common mistakes in binary, hex and two’s complement
- Dropping leading zeros. For 8 bits, 99 is 01100011. In two’s complement that leading 0 marks the number as positive.
- Grouping nibbles from the left. Always group from the right: 101101 is 0010 1101 = 2D.
- Forgetting to add 1. Inverting 00101101 gives 11010010, which is -46. Add 1 to reach 11010011, which is -45.
- Reading the wrong system. 11010011 is 211 unsigned and -45 in two’s complement. Check which the question states.
- Writing hex digits as numbers. 14 is E and 10 is A. Writing 1410 for EA is wrong.
- Going out of range. 8-bit two’s complement stops at 127 and -128.
- Mixing kB and KiB. 1 kB is 1,000 bytes and 1 KiB is 1,024 bytes.
- Skipping the check. Convert every answer back before moving on.
If these slips keep repeating in school tests, regular practice with feedback fixes them. Our G3 Computing tuition builds that routine across all five modules.
Frequently asked questions
What is two’s complement in O-Level Computing?
Two’s complement represents positive and negative whole numbers in a fixed number of bits, with a negative place value on the leftmost bit. In 8 bits that bit is worth -128, so the range is -128 to 127. It is learning outcome 1.2.3 in G3 Computing (Syllabus K349).
How do you convert binary to hexadecimal?
Split the binary into groups of four bits from the right, padding with zeros on the left, then convert each group to one hex digit. For example, 10110101 becomes 1011 0101, which is B5.
Is binary addition in the O-Level / G3 Computing syllabus?
Module 1.2 of G3 Computing (Syllabus K349) lists binary for positive whole numbers, binary, denary and hexadecimal conversion, two’s complement and 8-bit extended ASCII. Binary addition and overflow are absent from that list.
What is the difference between a kilobyte and a kibibyte?
A kilobyte (kB) is 1,000 bytes and a kibibyte (KiB) is 1,024 bytes. Learning outcome 1.1.1 expects calculations with both.
Is G3 Computing (Syllabus K349) the same subject as O-Level Computing?
From 2027 the subject sits under the Singapore-Cambridge Secondary Education Certificate (SEC) as G3 Computing, subject code K349. K349 replaces O-Level Computing 7155 from 2027, with the same content for this topic.
Sources and syllabus reference
Master Module 1 with weekly G3 Computing tuition
Computhink Academy has been teaching since 2015, with weekly G3 Computing tuition at Computhink@ToaPayohLibrary (6 Toa Payoh Central) or online. Book a free trial lesson and work through conversions and two’s complement with a tutor.