title: Two's complement addition overflow in C
body: <p>I saw a buggy code in C which was used to check whether addition results in overflow or not. It works fine with <code>char</code>, but gives incorrect answer when arguments are <code>int</code> and I couldn't figure why .<br>
  Here's the code with <code>short</code> arguments.</p>
  
  <pre><code>short add_ok( short x, short y ){
      short sum = x+y;
      return (sum-x==y) &amp;&amp; (sum-y==x);
  }
  </code></pre>
  
  <p>This version works fine, problem arise when you change arguments to <code>int</code> ( you can check it with <code>INT_MAX</code> )<br>
  Can you see what's wrong in here ?</p>