Skip to main content
Logo image

Dive Into Systems: Exercises

Section 4.1 Binary Representation

Exercise 4.1.1. Binary Representation.

How many unique values can a 5-bit value represent?

Exercise 4.1.2. Binary Terminology.

    Which of the following is the name of the "default" size that a system’s hardware uses when moving data from one component to another (e.g., between memory and registers)?
  • word
  • Correct!
  • bit
  • Incorrect.
  • byte
  • Incorrect.
  • chunk
  • Incorrect.

Exercise 4.1.3. Binary and C Types.

    Which of the following statements are true about a char value?
  • It is stored as a binary value.
  • Correct!
  • It is an 8-byte value.
  • Be careful not to confuse bits with bytes.
  • It is widely used to represent a character.
  • Correct!
  • A single char can represent an infinite number of unique values/characters.
  • char is a finite size so it can represent a finite number of values.

Exercise 4.1.4. Binary Representation.

Imagine that you are designing a language to speak to a robot. The robot has the following actions it can take: start, stop, turn left, turn right, and jump. How many bits would be needed to represent this set of commands?
bits
Hint.
How many unique values do you need to represent?

Exercise 4.1.5. Binary Representation.

Assume that you want to represent the four cardinal directions (North, South, East, and West) using 2 bits as follows:
North: 00
South: 01
East: 10
West: 11
Give the sequence of directions that is represented by the following binary value, using N for north, S for south, E for east, and W for west.
001011000111
Hint.
Starting from the left, divide this binary value into groups of 2 bits.