title: Floating point overflow and inexactness
body: <p>I found some inconsistencies in handling floating point errors on Intel hardware and I'm wondering if this is Intel hardware error or just general way of how floating point aritmetic work. Scenarios:</p>
  
  <p>1) 10000 + maxfloat = 3.40282e+38
     error produced: FE_INEXACT</p>
  
  <p>2) maxfloat + maxfloat = inf
     errors: FE_OVERFLOW, FE_INEXACT</p>
  
  <p>3) 1.1 * maxfloat = inf
     errors: FE_OVERFLOW, FE_INEXACT</p>
  
  <p>Scenario 1 is inconsisten with other two because I was exceeding float range but I did not get overflow like in case 2 and 3. </p>
  
  <p>I can not comprehend why I don't get overflow and number just saturates in first case but in second and third number is not saturated and I get overflow.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;limits&gt;
  #include &lt;cstdio&gt;
  #include &lt;cfenv&gt;
  
  void print_error() {    
      const int err = fetestexcept(FE_ALL_EXCEPT);
      if (err &amp; FE_INVALID) cout &lt;&lt; "FE_INVALID " &lt;&lt; endl;            
      if (err &amp; FE_DIVBYZERO) cout &lt;&lt; "FE_DIVBYZERO "&lt;&lt; endl;
      if (err &amp; FE_OVERFLOW) cout &lt;&lt; "FE_OVERFLOW "&lt;&lt; endl;        
      if (err &amp; FE_UNDERFLOW) cout &lt;&lt; "FE_UNDERFLOW " &lt;&lt; endl;
      if (err &amp; FE_INEXACT) cout &lt;&lt; "FE_INEXACT " &lt;&lt; endl;
      cout &lt;&lt; endl;      
  }
  
  int main() {
      feclearexcept(FE_ALL_EXCEPT);        
      cout &lt;&lt; numeric_limits&lt;float&gt;::max() + 100000.0f &lt;&lt; endl;
      print_error();
  
      feclearexcept(FE_ALL_EXCEPT);        
      cout &lt;&lt; numeric_limits&lt;float&gt;::max() + numeric_limits&lt;float&gt;::max() &lt;&lt; endl;
      print_error();    
  
      feclearexcept(FE_ALL_EXCEPT);
      cout &lt;&lt; 1.1f*numeric_limits&lt;float&gt;::max() &lt;&lt; endl;
      print_error();
  }
  </code></pre>