Question: [8] This exercise is about the bit-wise operators in C. Complete each function skeleton using only straight-line code (i.e., no loops, conditionals, or function calls)

 [8] This exercise is about the bit-wise operators in C. Complete

[8] This exercise is about the bit-wise operators in C. Complete each function skeleton using only straight-line code (i.e., no loops, conditionals, or function calls) and limited of C arithmetic and logical C operators. Specifically, you are only allowed to use the following eight operators: ! ~& [ +. A specific problem may restrict the list further: For example, write a function to compute the bitwise xor of x and y, only using & , int bitXor(int x, int y) { return ((x&~y) | (~x & y));} ~ and */ (a) /* bitAnd: x&y Ex: bitAnd(6, 5) = 4 Legal ops: int bitAnd(int x, int y) {return 2; } ~& + > * (b) /* minusOne: return -1; Legal ops: ! int minus1 (void) {return 2; } isPositive (-1) (C) /* ispositive: 0 Legal ops: return 1 if x >= 0, else return 0; Ex: ! ~& + > */ int is Positive(int x) { return 2;} (d) /* twoCmax: return maximum two's complement integer Legal ops: ! ~& + */ int twoCmax (void) return 2; } (void)

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!