title: Is static_cast<int>(std::numeric_limits<double>::infinity()) defined behaviour?
body: <p>The following code (<a href="https://onlinegdb.com/Skl8osMPL" rel="nofollow noreferrer">online here</a>):</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;limits&gt;
  
  int main()
  {
      double dinf = std::numeric_limits&lt;double&gt;::infinity();
      float finf = std::numeric_limits&lt;float&gt;::infinity();
  
      printf("Double infinity = %f, float = %f\n", dinf, finf);
      printf("Negative double infinity = %f, float = %f\n", -dinf, -finf);
      printf("Double infinity as int = %d, float = %d\n", static_cast&lt;int&gt;(dinf), static_cast&lt;int&gt;(finf));
      printf("Double infinity as uint = %d, float = %d\n", static_cast&lt;unsigned int&gt;(dinf), static_cast&lt;unsigned int&gt;(finf));
      printf("Negative double infinity as int = %d, float = %d\n", static_cast&lt;int&gt;(-dinf), static_cast&lt;int&gt;(-finf));
      printf("Negative double infinity as uint = %d, float = %d\n", static_cast&lt;unsigned int&gt;(-dinf), static_cast&lt;unsigned int&gt;(-finf));
      printf("dinf == finf is %s\n", dinf == finf ? "TRUE" : "FALSE");
      printf("dinf == -dinf is %s\n", dinf == -dinf ? "TRUE" : "FALSE");
      printf("int(dinf) == int(-dinf) is %s\n", static_cast&lt;int&gt;(dinf) == static_cast&lt;int&gt;(-dinf) ? "TRUE" : "FALSE");
  
      return 0;
  }
  </code></pre>
  
  <p>Gives me these results:</p>
  
  <pre><code>Double infinity = inf, float = inf                                                                                      
  Negative double infinity = -inf, float = -inf                                                                           
  Double infinity as int = -2147483648, float = -2147483648                                                               
  Double infinity as uint = 0, float = 0                                                                                  
  Negative double infinity as int = -2147483648, float = -2147483648                                                      
  Negative double infinity as uint = 0, float = 0                                                                         
  dinf == finf is TRUE                                                                                                    
  dinf == -dinf is FALSE                                                                                                  
  int(dinf) == int(-dinf) is TRUE                                                                        
  </code></pre>
  
  <p>Looking at <a href="https://en.cppreference.com/w/cpp/types/numeric_limits/infinity" rel="nofollow noreferrer">this page</a>, it tells me that <code>std::numeric_limits&lt;int&gt;::infinity()</code> is <code>0</code>, so why does both <code>static_cast&lt;int&gt;(std::numeric_limits&lt;double&gt;::infinity())</code> and <code>static_cast&lt;int&gt;(-std::numeric_limits&lt;double&gt;::infinity())</code> return <code>INT_MIN</code>? What does the standard say?</p>