Question: please explain the logic behind this code. the code works but i just need an explanation please. * isGreater - if x > y then
please explain the logic behind this code. the code works but i just need an explanation please.
* isGreater - if x > y then return 1, else return o Example: isGreater(4,5) = 0, isGreater(5,4) - 1 Legal ops: !^&^ + > Max ops: 24 Rating: 3 */ int isGreater(int x, int y) { int sgnext_x = x >> 31; int sgnext_y = y >> 31; int sgn_y = sgnext_y & 1; int minus = x + (wy + 1); int sgn_minus = (minus >> 31) & 1; int which = sgnext_x *sgnext_y; int final = (!!(x+y)) & ((which & sgn_y) | (!(which (sgn_minus)))); return final; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
