Question: please explain the logic behind this code. it works i just need an explanation . * * * * addOK Determine if can compute x+y
please explain the logic behind this code. it works i just need an explanation . 
* * * * addOK Determine if can compute x+y without overflow Example: addok (0x80000000,0x80000000) 0, addok (0x80000000,0x70000000) 1, Legal ops: ! ^&^ + > Max ops: 20 Rating: 3 */ int addok (int x, int y) { int mask = 0x1; int signx (x>>31)&mask; int signy = (y>>31)&mask; int zero = signy-signx; int sum = (x+(my+1))>>31; int sumsign = (sum&mask)*signx; return !(sumsign&zero); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
