signed/unsigned int mismatch
<p>The following program gives a signed/unsigned mismatch warning:</p>

<pre><code>#include &lt;iostream&gt;

int main()
{
unsigned int a = 2;
int b = -2;

if(a &lt; b)
    std::cout &lt;&lt; "a is less than b!";

return 0;
}
</code></pre>

<p>I'm trying to understand the problem when it comes to mixing signed and unsigned ints. From what I have been told, an int is typically stored in memory using two's complement.</p>

<p>So, let's say I have the number 2. Based on what I understand it will be represented in memory like this:</p>

<pre><code>00000000 00000000 00000000 00000010
</code></pre>

<p>And -2 will be represented as the one's compliment plus 1, or:</p>

<pre><code>11111111 11111111 11111111 11111110
</code></pre>

<p>With two's compliment there is no bit reserved for the sign like the "Sign-and-magnitude method". If there is no sign bit, why are unsigned ints capable of storing larger positive numbers? What is an example of a problem which could occur when mixing signed/unsigned ints?</p>
