CodeIEB
CodeIEB/🧪 Skills Lab/Binary, Hex & ASCII
🔢 Number Systems

Binary, Hex & ASCII

Every value a computer stores is ultimately binary. This page walks through converting between decimal, binary and hexadecimal, and how characters are represented as numbers — then tests you with exam-style questions.

Decimal → Binary: the division method

Repeatedly divide the number by 2, writing down the remainder each time, until you reach 0. Reading the remainders from bottom to top gives you the binary value.

Try it yourself — enter a decimal number to see the conversion, step by step:

Value÷ 2QuotientRemainder
45÷ 2221
22÷ 2110
11÷ 251
5÷ 221
2÷ 210
1÷ 201

Read the remainders from bottom to top:

Binary

101101

Hexadecimal

2D

Binary ↔ Hexadecimal: group into 4s

Each hexadecimal digit represents exactly 4 binary bits, which makes conversion fast: group the binary digits into sets of 4 (starting from the right), then convert each group.

1101 1010
 D    A   → DA (hex)

ASCII: characters as numbers

ASCII assigns every character a unique number. A handful of values come up constantly in exam questions — worth memorising:

Character(s)ASCII code
'0'–'9'48
'A'65
'Z'90
'a'97
'z'122
space32

Handy trick: uppercase and lowercase letters are exactly 32 apart (e.g. 'A' = 65, 'a' = 97).

Test yourself

0/19 answered

Question 1

Convert the decimal number 45 to binary.

Question 2

Convert the binary number 110101 to decimal.

Question 3

How many unique combinations (values) can be represented using 6 bits?

Question 4

An unsigned integer is stored using 8 bits. What is the maximum value that can be represented?

Question 5

Convert the binary number 1101 1010 to hexadecimal.

1101 1010

Question 6

What is the ASCII decimal code for the uppercase letter 'A'?

Question 7

Why does Unicode/UTF-8 exist alongside the older ASCII standard?

Question 8

A calculation on an 8-bit unsigned integer produces the result 250 + 10 = 260. What happens?

Question 9

Convert the decimal number 200 to hexadecimal.

Question 10

A screen uses 8 bits per colour channel (Red, Green, Blue). How many distinct colours can a single pixel display?

Question 11

Convert the hexadecimal number 2F to decimal.

Question 12

What is the ASCII decimal code for the digit character '5' (not the number 5, the character)?

Question 13

Add the binary numbers 0101 and 0011.

0101 + 0011

Question 14

Convert the decimal number 100 to binary.

Question 15

Convert the hexadecimal number FF to decimal.

Question 16

Why do programmers often use hexadecimal instead of binary when representing byte values (e.g. colour codes, memory addresses)?

Question 17

What is the ASCII decimal code for the lowercase letter 'z'?

Question 18

A file is 2,097,152 bytes in size. How many megabytes (MB) is this, using 1 MB = 1,048,576 bytes?

Question 19

Subtract the binary numbers: 1010 − 0011.

1010 - 0011