Question: More Bit Manipulation - C Programming Write the function bit check(int data, int bits on, int bits off), to check an int to see if

More Bit Manipulation - C Programming

Write the function bit check(int data, int bits on, int bits off), to check an int to see if a specific set of bits (aka a bit mask, call it bits on) is set AND that another set of bits (bits off) is clear. Returns 1 if the int called data matches the bit masks, and 0 if not.

However, note there is a special case. For example, suppose I write 1

int data = 0xFF; bit_check(data, 0x32, 0x20);

theres a problem! Because 0x32 & 0x20 = 0x20 , we are asking that bit 0x20 must be BOTH off and on! Your function should return -1 for any case of testing that any bit is BOTH off and on.

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 Programming Questions!