Binary, octal, hexadecimal, character codes and logic gates
JAMBWAECNECO
What the syllabus asks
JAMB: Section B 1(d) Logic circuits (AND, NOT, OR, NOR, NAND; logic equations for AND, NOT, OR; symbols; truth tables; comparator using XOR and NOR); 2(b) Data representation: types of data (integers, real numbers, strings, multimedia); number bases with special reference to binary, decimal, hexadecimal; 2(c) digitisation
WAEC: Logic circuits (definition, types, uses, symbols, logic equations, truth tables for AND, NOT, OR, NAND, NOR; comparator with XOR and NOR)
NECO: Logic circuits (definition, types, uses, symbols, logic equations, truth tables for AND, NOT, OR, NAND, NOR; comparator with XOR and NOR)
What you will learn
- Explain why computers use binary and list data types.
- Convert decimal numbers to binary, octal and hexadecimal.
- Convert binary, octal and hexadecimal numbers to decimal.
- Convert directly between binary, octal and hexadecimal by grouping.
- Convert simple binary fractions.
- Add, subtract and multiply binary numbers.
- Describe character codes (ASCII, Unicode) and BCD.
- Draw the symbols and write the equations for AND, OR, NOT, NAND, NOR and XOR.
- Construct truth tables for single gates and simple circuits.
- Construct a simple comparator using XOR and NOR/NOT gates.
Key points
- Computers use binary because switches have two reliable states.
- Data types: integer, real, string, Boolean, multimedia.
- Bases: binary 2 (0–1), octal 8 (0–7), decimal 10, hexadecimal 16 (0–9, A–F).
- A digit must be less than its base.
- Decimal → base b: repeated division by b, remainders read bottom up.
- Base b → decimal: multiply digits by place values (powers of b) and add.
- Binary ↔ octal: groups of 3 bits; binary ↔ hex: groups of 4 bits.
- Binary fractions: places ½, ¼, ⅛; decimal fraction → binary by repeated ×2, read top down.
- Binary addition: 1+1 = 10, 1+1+1 = 11; subtraction uses borrowing.
- Two’s complement: invert bits, add 1.
- ASCII: A = 65, a = 97, 0 = 48; Unicode covers all scripts; BCD codes each decimal digit in 4 bits.
- AND: all 1 → 1 (A·B). OR: any 1 → 1 (A + B). NOT: inverts (Ā).
- NAND: 0 only when all 1. NOR: 1 only when all 0. XOR: 1 when inputs differ.
- Truth table rows = 2ⁿ for n inputs; NAND and NOR are universal gates.
- Comparator: XOR detects difference; NOT/NOR of XOR outputs gives 1 for equality.
Start here: Why binary? Data types and representation
Inside a computer, every piece of data, whether a number, a letter, a photo or a song, is stored as patterns of binary digits (bits): 0 and 1. The reason is physical: electronic components such as transistors work reliably as switches with two states, off (0) and on (1). Two states are easy to tell apart even when voltages vary slightly, so binary circuits are simpler, cheaper and more reliable than circuits that would have to tell ten voltage levels apart.
Types of data (JAMB syllabus)
- Integers: whole numbers, positive or negative: 25, −7, 2026.
- Real (floating-point) numbers: numbers with fractional parts: 3.75, −0.5, 98.6.
- Strings (alphanumeric): sequences of characters: “Abuja”, “SS3B”, “NIN 1234”.
- Boolean: true or false.
- Multimedia: images (grids of pixels, each a number), audio (sound waves sampled into numbers), video (a series of images plus sound), and signals from sensors.
Number systems in computing
Programmers use hexadecimal and octal as shorthand for long binary strings, because 16 = 24 and 8 = 23; each hex digit stands for exactly four bits and each octal digit for three. Hex appears in colour codes for web pages (#FF0000 is pure red), in memory addresses and in MAC addresses of network cards.
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
Learn this table: it makes grouping conversions quick. A subscript shows the base: 10102 = 1010 = 128 = A16.
Continue this lesson in the free app →
Practice questions
- 1101
- 1011
- 1110
- 1001
Show answer
A: 1101
13 = 8 + 4 + 1.
- 26
- 20
- 18
- 22
Show answer
D: 22
16 + 4 + 2 = 22.
- F0
- FE
- FF
- EF
Show answer
C: FF
255 = 15×16 + 15.
- 32
- 31
- 15
- 25
Show answer
B: 31
1×16 + 15 = 31.
- 31
- 37
- 29
- 24
Show answer
A: 31
3×8 + 7 = 31.
Key words
- Number base (radix)
- The number of distinct digits used in a place-value number system.
- Binary
- Base 2, using digits 0 and 1.
- Octal
- Base 8, using digits 0–7.
- Decimal
- Base 10, using digits 0–9.
- Hexadecimal
- Base 16, using 0–9 and A–F.
- Place value
- The value of a position: a power of the base.
- Most significant bit (MSB)
- The leftmost bit, with the highest place value.
- Least significant bit (LSB)
- The rightmost bit, with place value 1.
- Carry
- A digit passed to the next column when a column sum reaches the base.
- Two’s complement
- A way of representing negative binary numbers: invert all bits and add 1.
- ASCII
- American Standard Code for Information Interchange: 7-bit codes for characters.
- Unicode
- A character code standard covering the scripts of the world’s languages.
The Cara's Tips app teaches every topic from the very basics, with quick checks, worked examples and exam practice. It works offline.
Open this lesson in the free appDownload for Android