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
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