Conversion conventions for all Number Systems in C

This project was a part of Principles of Embedded Software Course, that I took at University of Colorado Boulder. The main aim of the project was to perform inter- number system conversions in the most efficient way possible without using division, multiplication or any mathematical operations and just bitwise operations.

The required set of functions that perform the set of operations are listed below:

  1. Binary representation of an unsigned integer.

  2. Binary representation of a signed integer.

  3. Hexadecimal representation of an unsigned integer.

  4. Twiggling any bit of a 32-bit number to SET, CLEAR or TOGGLE.

  5. Grabbing of any 3 bits with respect to user input and shifting them to the left and making all other bits CLEAR.

  6. Generate a string representing a “dump” of hexadecimal data.

  7. Reverse the bits of a 8-bit number such that all the bits are swapped, i.e. 1-7,2-6..and so on.

  8. A test function for each of the aforementioned functions that covers all the values.

All the functions enlisted above are based on bitwise operations and no division, multiplication or any mathematical operations are used. Each function has its own set of parameters and return values that are ellaborated in the header files. The main functions of this assignment are the following:

Click on any function to see how bitwise operators are used to perform aforementioned operations.

All the test cases pertaining to the respective functions are mentioned in test.c file with multiple iterations of tests for each function. The functions implemented in Test.c file are all called through main.c and output is given with respect to return values of these test functions. Please refer Github repository for more information.