title: C++ : integer constant is too large for its type
body: <p>I need to bruteforce a year for an exercise. The compiler keep throwing this error:</p>
  
  <blockquote>
    <p>bruteforceJS12.cpp:8:28: warning: integer constant is too large for its type [enabled by default]</p>
  </blockquote>
  
  <p>My code is:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main(){
  
      unsigned long long year(0);
      unsigned long long result(318338237039211050000);
      unsigned long long pass(1337);
  
      while (pass != result)
      {
      for (unsigned long long i = 1; i&lt;= year; i++)
          {
  
          pass += year * i * year;
  
          }
  
          cout &lt;&lt; "pass not cracked with year = " &lt;&lt; year &lt;&lt; endl;
          ++year;
  
      }
  
          cout &lt;&lt; "pass cracked with year = " &lt;&lt; year &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Note that I already tried with <code>unsigned long long result(318338237039211050000ULL);</code></p>
  
  <p>I'm using gcc version 4.8.1</p>
  
  <p>EDIT:</p>
  
  <p>Here is the corrected version using InfInt library <a href="http://code.google.com/p/infint/" rel="nofollow">http://code.google.com/p/infint/</a></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "InfInt.h"
  
  using namespace std;
  
  int main(){
  
      InfInt year = "113";
      InfInt result = "318338237039211050000";
      InfInt pass= "1337";
  
      while (pass != result)
      {
      for (InfInt i = 1; i&lt;= year; i++)
          {
  
          pass += year * i * year;
  
          }
  
          cout &lt;&lt; "year = " &lt;&lt; year &lt;&lt; "  pass = " &lt;&lt; pass &lt;&lt;  endl;
          ++year;
  
      }
  
          cout &lt;&lt; "pass cracked with year = " &lt;&lt; year &lt;&lt; endl;
  }
  </code></pre>