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 . please explain the logic behind this code. it works i just need

* * * * 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

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!