CARA'S TIPS
Computer Studies / Data Processing · Lesson 4

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

Key points

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)

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.

DecimalBinaryOctalHex
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F

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

1. Convert 13₁₀ to binary.
  1. 1101
  2. 1011
  3. 1110
  4. 1001
Show answer

A: 1101
13 = 8 + 4 + 1.

2. Convert 10110₂ to decimal.
  1. 26
  2. 20
  3. 18
  4. 22
Show answer

D: 22
16 + 4 + 2 = 22.

3. Convert 255₁₀ to hexadecimal.
  1. F0
  2. FE
  3. FF
  4. EF
Show answer

C: FF
255 = 15×16 + 15.

4. Convert 1F₁₆ to decimal.
  1. 32
  2. 31
  3. 15
  4. 25
Show answer

B: 31
1×16 + 15 = 31.

5. Convert 37₈ to decimal.
  1. 31
  2. 37
  3. 29
  4. 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.
Learn Binary, octal, hexadecimal, character codes and logic gates step by step, free.
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