Question
/* question 13 */ int ques13(int x) { int mask1, mask2, mask4, mask8, mask16; mask2 = 0x33 + (0x33 < < 8); mask2 += mask2
/* question 13 */
int ques13(int x) {
int mask1, mask2, mask4, mask8, mask16;
mask2 = 0x33 + (0x33 << 8); mask2 += mask2 << 16; mask1 = mask2 ^ (mask2 << 1); mask4 = 0x0F + (0x0F << 8); mask4 += mask4 << 16; mask8 = 0xFF + (0xFF << 16); mask16 = 0xFF + (0xFF << 8);
x = (x & mask1) + ((x >> 1) & mask1); x = (x & mask2) + ((x >> 2) & mask2); x = (x & mask4) + ((x >> 4) & mask4); x = (x & mask8) + ((x >> 8) & mask8); x = (x & mask16) + ((x >> 16) & mask16);
return x; }
show and explain the output when input is positive negative or zero and then give a simplify version of function
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