title: C++ Double size/ overflow questions
body: <p>I have recently come across something weird that I am having trouble understanding.</p>
  
  <p>Basically I was trying to estimate the number of seconds that have passed in the last 2014 years. However the results that I was getting were negative numbers. I thought at first that it was some kind of overflow due to the size limitations of a double floating point variable, however after looking into that it seems that this is not the case. So I started to play around with the following code:</p>
  
  <pre><code>double test = 1.8*pow(10,308);
  cout &lt;&lt; test &lt;&lt; endl;
  test = 1.7*pow(10,308);
  cout &lt;&lt; test &lt;&lt; endl;
  test = 2*1000000000;
  cout &lt;&lt; test &lt;&lt; endl;
  test = 2*100*100*100*100*100;
  cout &lt;&lt; test &lt;&lt; endl;
  test = 1*1000000000;
  cout &lt;&lt; test &lt;&lt; endl;
  test = 1*100*100*100*100*100;
  cout &lt;&lt; test &lt;&lt; endl;
  </code></pre>
  
  <p>This returned the following output:</p>
  
  <pre><code>inf
  1.7e+308
  2e+009
  -1.47484e+009
  1e+009
  1.41007e+009
  </code></pre>
  
  <p>The first two results make sense to me. I am under the impression that 1.7e+308 is the maximum possible value that can be stores in a double, which means that 1.8e+308 wouldn't work - so the compiler interprets this as infinity?
  However after that things become a little confusing. </p>
  
  <p>I don't understand why 2*10000000000 and 2*100*100*100*100*100 return different values?</p>
  
  <p>Or why 1*10000000000 and 1*100*100*100*100*100 don't return that same value? </p>
  
  <p>I also don't understand why 2*100*100*100*100*100 returns a negative value?</p>
  
  <p>Also where is the 1.4... coming from when I am only multiplaying by 1 or 2?</p>
  
  <p>If someone could help me understand this better it would be appreciated!</p>