title: unsigned long long int pow
body: <p>I have the following power function which operates on integers and it works fine:</p>
  
  <pre><code>int ipow( int base, int exp )
  {
      int result = 1;
      while( exp )
      {
          if ( exp &amp; 1 )
          {
              result *= base;
          }
          exp &gt;&gt;= 1;
          base *= base;
      }
      return result;
  }
  </code></pre>
  
  <p>Now I'd like to have a version which allows exp > 32. So I use unsigned long long ints:</p>
  
  <pre><code>unsigned long long int ipow( int base, int exp )
  {
      unsigned long long int result = 1ULL;
      while( exp )
      {
          if ( exp &amp; 1 )
          {
              result *= (unsigned long long int)base;
          }
          exp &gt;&gt;= 1;
          base *= base;
      }
      return result;
  }
  </code></pre>
  
  <p>But this second version doesn't seem to work:</p>
  
  <pre><code>unsigned long long int x;
  x = ipow( 2, 35 );
  printf( "%llu\n", x );
  </code></pre>
  
  <p>this will output 0. </p>
  
  <p>What's the problem with my unsigned long long int implementation?</p>