Topic 1b
Binary and Hexadecimal Integer Representations

Learning Outcomes

By the end of this topic students should be able to:

  • Convert a binary representation (unsigned integer) to its equivalent base ten value.
  • Convert a base ten value to its binary equivalent (unsigned integer).
  • Convert a length 4 binary representation (unsigned integer) to its equivalent hexadecimal value.
  • Convert a hexadecimal value to its binary equivalent (unsigned integer).
  • Calculate the sum of two bit-strings with the solution expressed as a bit string.
  • Calculate how many unique values can be stored in N bits.

 

Learning Materials

  • Unplugged Activity
    • When this course has a face-to-face component I conduct a little "magic trick" to engage with my students and the fun part is that the "trick" is a great reinforcement of binary.
    • It's hard to model this activity online without being with you. But let me try:
      • Think of a number from 1 to 63.
      • Open this page of six cards filled with numbers.
      • For each of the six cards, identify if your number was on the card or not.
      • I guarantee you that if we were in the classroom and you told me which cards had your number on it I could tell you your number. You will just have to believe me when I tell you that I can.
      • The "trick" is easy
        • Consider the number in the upper left hand corner of each of the cards that contain your number.
        • Add up those numbers.
        • They will add up to the number you are thinking about.
        • Wait, WHAT? HOW?
        • Well, let's put this on hold until after you complete today's readings.
  • Readings
    • Binary representation of non-negative integers - pp 51-54
    • Hexadecimal - pp 32-33
  • Videos
  • Back to Unplugged
    • Let's reconsider the cards in light of what you just read.
    • Consider the upper left hand corner of every card. What do you notice about these numbers and how they tie back to what we just read? Notice that these are all powers of two and match the first six of eight bits in a binary integer encoding.
    • Binary Magic Cards Instructions
  •  

Checking for Understanding

If you want to get some practice working with binary you can use the following resources

 

Answer the following questions from your textbook. The answers to all Q&E questions are in the back of your book in Appendix F.

  • p56, #1
  • p56, #2
  • p56, #5 a and c (b&d are covered in the next topic)
  • p34, #5
  • p34, #6

 

Answers & Guidance

The answers to the CFU questions above are provided in the back of the book. The following videos explain how we would arrive at some of those answers.
  • From binary strings to integers
    • CFU p56, #1
      • Note, we have a typo in the slides for 1e. There are only four 1s (which is 15) but the book has five 1s (which is 16+15 or 31).
  • From integers to binary strings
  • From binary strings to hexadecimal

Further Information

If you want to see someone else explain this material, you might use these resources. Again, this material is a supplement to this course and is completely optional.