DoAssignment study guide
A1.2 · Explain binary, hexadecimal, and character encoding
Learn to explain binary, hexadecimal, and character encoding through clear examples and targeted practice.
Ontario Grade 11 Computer Science
Programming Concepts and Skills
How number systems and shared rules represent information
What you will learn
- Explain how binary place values represent whole numbers.
- Convert binary values to hexadecimal by grouping bits in fours.
- Explain how character encodings connect characters with numeric codes and bytes.
1. Binary: numbers with two digits
- Binary is base 2 and uses only 0 and 1.
- From right to left, binary place values are 1, 2, 4, 8, 16, and so on.
- To find a binary numeral's decimal value, add the place values marked by 1.
2. Hexadecimal: a compact way to write values
- Hex is base 16 and uses 0–9 and A–F.
- Each hex digit represents one group of four bits.
- Group binary bits from the right; pad a short leftmost group with zeroes.
3. Character encoding: rules for representing text
- Character-encoding rules connect characters with numeric codes or byte patterns.
- ASCII covers a limited set; Unicode assigns code points across many writing systems.
- UTF-8 encodes Unicode text as bytes, using multiple bytes for some characters.
4. Keep the representations distinct
- Binary and hex are different notations for number values.
- An encoding is needed to interpret bytes as text.
- A character can be represented by more than one byte.
Trace of the UTF-8 example
| Stage | Value |
|---|---|
| Input text | é |
| After UTF-8 encoding | bytes C3 A9 |
| After hexadecimal display | c3a9 |
Worked example
Read a binary number
Each cell pairs a bit with its binary place value.
- Match bits to placesStarting at the right, match the six bits to place values 1, 2, 4, 8, 16, and 32. Include only the values whose matching bit is 1.
- Add the selected valuesThe zero bits leave out the 16 and 2 places. Adding the selected values gives the decimal result.
Worked example
Convert binary to hexadecimal
The first four bits make D; the second four bits make 6.
- Group the bitsStarting from the right, divide the eight bits into two groups of four. No padding is needed because both groups already contain four bits.
- Convert each groupThe first group has value thirteen, represented by D in hexadecimal. The second group has value six, represented by 6.
Worked example
Trace UTF-8 bytes for a character
The first eight bits form byte C3; the next eight form byte A9.
Python 3
text = "é"
encoded = text.encode("utf-8")
print(encoded.hex())- Identify the input and encodingThe input is a string containing the single character é. The code requests UTF-8 encoding; under that rule, this character is represented by byte values C3 and A9.
- Trace the hexadecimal displayAfter encoding, encoded holds the bytes for C3 A9. The hex method returns their hexadecimal digits as the string c3a9, and print displays that string. The code does not print the bytes object's representation.
Common mistakes and how to avoid them
Lesson summary
- Binary uses 0 and 1, with powers of two as place values.
- Hexadecimal uses 0–9 and A–F; each hex digit represents four bits.
- Character encodings connect characters with numeric codes or byte patterns.
- ASCII covers a limited character set. Unicode assigns code points across many writing systems, and UTF-8 encodes Unicode text as bytes.
- A character may use more than one byte, and byte patterns need an encoding to be interpreted as text.
Check your understanding
Question 1
- 18
- 10
- 20
- 10010
Show answer and explanation
Question 2
- 1011
- 1100
- 1001
- 1110
Show answer and explanation
Question 3
- It encodes Unicode text as bytes, using one or more bytes for a character.
- It makes every character exactly one byte long.
- It converts every number to hexadecimal.
- It is another name for binary place values.
Show answer and explanation
Key terms
- Bit
- A binary digit with value 0 or 1.
- Byte
- A group of eight bits.
- Binary
- A base-2 number system using 0 and 1.
- Hexadecimal
- A base-16 number system using 0–9 and A–F.
- Character encoding
- A set of rules connecting characters with numeric codes or byte patterns.
- Unicode
- A standard that assigns code points to characters across many writing systems.
- UTF-8
- A way of encoding Unicode text as bytes.
Continue through ICS3U
View the complete ICS3U Ontario Grade 11 Computer Science curriculum and lessons
- A1.1 · Use variables and constants with appropriate data types
- A1.3 · Use arithmetic and string assignment statements
- A1.4 · Use Boolean, comparison, and arithmetic operators correctly
- A1.5 · Explain one-dimensional arrays, indexes, and bounds
- A1.6 · Create and update one-dimensional arrays in a program
- A2.1 · Write a program with input, processing, and output
About this lesson and its review
Published by DoAssignment. This reviewed lesson follows Ontario Grade 11 Computer Science (ICS3U), expectation A1.2. It is a study resource, not an official curriculum publication.
Before publication, content is checked for structure, mathematical or chemical notation, calculations, course boundaries, and readability. Errors can still occur, so corrections are welcomed.