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
- 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. Furthermore, dont use an array such as bit[i] . 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.
- 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started