Bit Manipulation

Manipulating bits is a very common task in embedded systems. Unfortunately, most high-level programming languages don't support operations on individual bits. In order to manipulate bits in high-level languages, bitwise logic operators must be used. In this lab, you will use these bitwise operators to perform several bit manipulation tasks.


  1. Download the provided code ( bitmanip.h, bitmanip.cc, main.cc, Makefile)
  2. The file bitmanip.cc contains empty function definitions for all of the bit manipulation tasks you will be implementing.
  3. Implement the following function in bitmanip.cc:
  4. Use the following C++ operators:
  5. Add at least 10 test cases for each function to the main.cc file. Make sure to use asserts for each test case. Several example test cases are provided.
  6. Compile and test your code on hill.cs.ucr.edu. Use the provided Makefile.
  7. Once you have all the test cases completed, have the TA check you out and turn in your code online.
  8. Useful logic operations: