title: (-2147483648> 0) returns true in C++?
body: <p>-2147483648 is the smallest integer for integer type with 32 bits, but it seems that it will overflow in the <code>if(...)</code> sentence:</p>
  <pre><code>if (-2147483648 &gt; 0)
      std::cout &lt;&lt; &quot;true&quot;;
  else
      std::cout &lt;&lt; &quot;false&quot;;
  </code></pre>
  <p>This will print <code>true</code> in my testing. However, if we cast -2147483648 to integer, the result will be different:</p>
  <pre><code>if (int(-2147483648) &gt; 0)
      std::cout &lt;&lt; &quot;true&quot;;
  else
      std::cout &lt;&lt; &quot;false&quot;;
  </code></pre>
  <p>This will print <code>false</code>.</p>
  <p>I'm confused. Can anyone give an explanation on this?</p>
  <hr />
  <p>Update 02-05-2012:</p>
  <p>Thanks for your comments, in my compiler, the size of int is 4 bytes. I'm using VC for some simple testing. I've changed the description in my question.</p>
  <p>That's a lot of very good replys in this post, <a href="https://stackoverflow.com/a/14695202/2040924">AndreyT</a> gave a very detailed explanation on how the compiler will behave on such input, and how this minimum integer was implemented. <a href="https://stackoverflow.com/a/14695400/2040924">qPCR4vir</a> on the other hand gave some related &quot;curiosities&quot; and how integers are represented. So impressive!</p>