Topic 1b — Binary and Hexadecimal Integer Representation

Understanding how 8 bits (1 byte) can represent integers in binary, decimal, and hexadecimal — and how to work flexibly between those representations.

Learning Objectives

By the end of this topic, you should be able to:

Learning Activities

To help you meet the learning objectives, we have prepared a combination of readings, activities, and videos.

Course Readings

These reading were designed to introduce the course topics to an audience of educators. They should be considered "required" and read in order.

Supplemental Readings

Some participants find it helpful to read about a topic from a source written for a slightly more technical audience. These supplemental readings cover similar material as the course readings but may not fully align with the course learning objectives. Use them as an optional complement to your study, not a substitute for the course readings.

Lesson Videos

These videos support the readings above and may present the material with some deeper connections and/or worked examples.

Checking for Understanding, Questions

Review the Learning Objectives from the top of this page. You will be asked to complete these types of problems on this week's competency demo. To help you check if you are on the right track with these concepts, use the following tools and questions as a type of formative self-assessment.

First, the following are two Scratch programs to help you practice conversion from decimal to binary and back again.

Next, consider the following questions. Try each one on your own before looking at the answer key. It is completely fine if you need to revisit the reading or video — that’s part of learning.

Binary → Decimal

  1. What base‑10 value does the 8‑bit binary number 01010011 represent?
  2. What base‑10 value does 11100001 represent?

Decimal → Binary (8‑bit, unsigned)

  1. Write the 8‑bit binary representation of the decimal number 19.
  2. Write the 8‑bit binary representation of the decimal number 200.

Binary ↔ Hexadecimal

  1. Convert the 4‑bit binary value 1010 to hexadecimal.
  2. Convert the hexadecimal digit D to its 4‑bit binary equivalent.
  3. Convert the 8‑bit binary number 10111100 to hexadecimal (two hex digits).
  4. Convert the hexadecimal value 3F to its 8‑bit binary equivalent.

How Many Values with N Bits?

  1. How many unique values can you represent with 8 bits?
  2. How many unique values can you represent with 10 bits?
  3. In general, how many unique values can you represent with N bits?

Checking for Understanding, Answers

You can begin be comparing your answers to the following answer key.

Show Answer Key

Binary → Decimal

  1. 01010011 = 64 + 16 + 2 + 1 = 83.
  2. 11100001 = 128 + 64 + 32 + 1 = 225.

Decimal → Binary

  1. 19 = 16 + 2 + 1 → 00010011.
  2. 200 = 128 + 64 + 8 → 11001000.

Binary ↔ Hexadecimal

  1. 1010 → decimal 10 → A.
  2. D → decimal 13 → binary 1101.
  3. 10111100 → group as 1011 1100 → B and C → BC.
  4. 3F → 3 → 0011, F → 111100111111.

How Many Values with N Bits?

  1. With 8 bits, you can represent 256 unique values (0–255).
  2. With 10 bits, you can represent 1024 unique values (0–1023).
  3. In general, with N bits, you can represent 2N unique values. N represents the number of "slots" or switches, and since each switch has 2 choices (0 or 1), we multiply 2 by itself N times.

If you still have questions or concerns you can use the videos below to try and further your understanding.

Extend Your Learning

The following resources go a little deeper on topics we touched on but did not fully explore in the readings. These are entirely optional — none of this material appears on the Competency Demo — but each one is a natural "next question" from something covered this week.

  • Binary addition
    Once you can convert between binary and decimal, a natural next question is: can you add two binary numbers directly, without converting first? The answer is yes, and the rules are surprisingly simple. This short reading walks through the four rules of binary addition with clear examples.
    Binary Addition