title: A C++ function to figure out whether one unsigned integer is bigger than another
body: <p>I was wondering if you guys could help me with a function I'm trying to make to determine whether an unsigned integer <code>a</code> is bigger than <code>b</code>. </p>
  
  <pre><code>#include &lt;limits.h&gt;
  #include &lt;iostream&gt;
  
  bool is_bigger(unsigned int a, unsigned int b)
  // returns true is a is bigger than b; returns false otherwise
  {
  
       for (int i = 0, j = sizeof(unsigned int) * CHAR_BIT; i &lt; j; ++i)
       {
          int b1 = (a &lt;&lt; i) &amp; (1 &lt;&lt; (j - i - 1));
          int b2 = (b &lt;&lt; i) &amp; (1 &lt;&lt; (j - i - 1));
          if (b2 &amp;&amp; !b1)
              return false;
       }
       return true;
  }
  
  int main()
  {
       unsigned int A = 0; 
       unsigned int B = 5;
       std::cout &lt;&lt; is_bigger(A, B);
  }
  </code></pre>
  
  <p>For some reason this program outputs <code>true</code> when it should be outputting <code>false</code>. Maybe something is wrong about my logic? Does anyone know of a library I can download that might have a function that can check whether one integer is bigger than another?</p>