title: why overflow when compare long long with int
body: <p>I'm writing a code like this</p>
  
  <pre><code>int reverse(int x) {
    long long res;
  
    ......
  
    if(x&gt;0&amp;&amp;res&gt;INT_MAX||x&lt;0&amp;&amp;res&gt;INT_MAX+1){
        return 0;
    }
    ......
  }
  </code></pre>
  
  <p>It shows overflow,but when I add conversion to this it complies</p>
  
  <pre><code>int reverse(int x) {
    long long res;
  
    ......
  
    if(x&gt;0&amp;&amp;res&gt;(unsigned long long)INT_MAX||x&lt;0&amp;&amp;res&gt;(unsigned long long)INT_MAX+1){
        return 0;
    }
    ......
  }
  </code></pre>
  
  <p>Can somebody please explain to me what is the problem?</p>