title: How to check if a sum/multiplication/subtraction creates overflow?
body: <p>So I am just trying to add two numbers together,</p>
  
  <p>The first one is <code>P1 = 2147483647</code> and the other is <code>P2 = 1</code>
  This should overflow the type int so I wrote this to try to prevent the computer from doing the overflow </p>
  
  <pre class="lang-c prettyprint-override"><code>if((P1 + P2) &gt; sizeof(int)){
      halt = 1; /*halt is just a flag*/
  }
  </code></pre>
  
  <p>But the computer obviously still tries to do the sum to check it, giving me a runtime error before the message I wrote that simply says that I cannot add those two number together. How can I do that without occurring into the runtime error and just displaying my message?</p>
  
  <p>I am also trying to do this for a subtraction and multiplication but the problem is the same.</p>
  
  <p>EDIT : I need to do this for a project, I don't think I can use the library limits.h</p>