Question: You are asked to implement the following C function:/* Return 1 when any odd bit of x equals 1; 0 otherwise. *//* Assure 32-bit integers
You are asked to implement the following C function:/* Return 1 when any odd bit of x equals 1; 0 otherwise. *//* Assure 32-bit integers */int any_odd_one(unsigned x) {return} Recall that the least-significant bit is numbered 0. Your code must be straight- code, i.e.. no conditionals, loops, function calls, etc. You are allowed to use only following operations: + > | - ! No comparison operators (. etc.), equality or inequality tests (==, !=), or are allowed. Also, you may only use constants no larger than 255 (decimal). Assume the variables a and b are signed integers and that the machine uses two's complement representation. Also, assume that MAX.INT is the maximum integer, and is the minimum integer. Simplify each line of code so it uses the absolute minimum number of &, level C operations Show your simplification steps. -(-a | (b - (MIN_INT + MAX_INT))) You are asked to implement the following C function:/* Return 1 when any odd bit of x equals 1; 0 otherwise. *//* Assure 32-bit integers */int any_odd_one(unsigned x) {return} Recall that the least-significant bit is numbered 0. Your code must be straight- code, i.e.. no conditionals, loops, function calls, etc. You are allowed to use only following operations: + > | - ! No comparison operators (. etc.), equality or inequality tests (==, !=), or are allowed. Also, you may only use constants no larger than 255 (decimal). Assume the variables a and b are signed integers and that the machine uses two's complement representation. Also, assume that MAX.INT is the maximum integer, and is the minimum integer. Simplify each line of code so it uses the absolute minimum number of &, level C operations Show your simplification steps. -(-a | (b - (MIN_INT + MAX_INT)))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
