Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

ISBN: 1844804526, 978-1844804528

More Books

Students also viewed these Databases questions