Question: Write functions with C++ programming : print_bits8(unsigned char b) print_bits16(unsigned short int b) print_bits32(unsigned int b) print_bits64(unsigned __int64 b) that print out unsigned integers b

  1. Write functions with C++ programming :

print_bits8(unsigned char b)

print_bits16(unsigned short int b)

print_bits32(unsigned int b)

print_bits64(unsigned __int64 b)

that print out unsigned integers b in binary notation. The bit number should also be printed above the binary number to make it easier to read a particular bit. For example,

unsigned short int b = 65000;

print_bits16(b);

prints out:

5432109876543210

1111110111101000

Use bit-wise operators to solve this problem -- dont use the binary number formulas from the pdf notes as you did in the previous assignment. Furthermore, dont use an array such as bit[i] used in the lecture examples. Start by finding bit-0, then bit-1 and so on. The bits, however, should be printed out in the normal order -- ie the higher bits before the lower bits as indicated in the example above. Write a main function that illustrates the functions using the example above.

  1. Modify the functions in part a) to work on the Arduino and test them with a setup function with the example from part a). Hint: use sizeof() to help identify which variable types are required to represent unsigned 8, 16, 32 and 64 (if possible) bit integers.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!