Exercises
The following exercises provide you with the opportunity to practice with bit vectors and bit manipulation. The solutions to these exercises are found in the section Chapter 12.
-
Write a function that accepts a binary string and returns the decimal number that the string represents. For example, if the function receives the string "100101", the function should return the integer 37. (Note that this is essentially the functionality of the Python expression 0b. However, this exercise is to build the same functionality from scratch.)
-
This exercise is the inverse of the previous exercise. Here, you are to write a function that receives a decimal number and returns a binary string. This binary string should always contain 32 bits, even ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access