Question: C++ (3) Write a function that will print an integer in binary format. HINT1: start at the highest order bit, which for a 4-byte integer

C++

 C++ (3) Write a function that will print an integer in

(3) Write a function that will print an integer in binary format. HINT1: start at the highest order bit, which for a 4-byte integer would be bit 31 . The most general way to specify the highest order bit no matter the byte size of integers is to use the expression sizeof(int)*8-1 for the highest order bit. Then, while bitnum is greater than or equal to zero, mask off that bit (see if it is a 0 or 1), print out either a 0 or 1 accordingly, and decrement bitnum. HINT2: for masking out a bit, you might have something similar to if (value \& (1

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!