title: Why does casting Double.NaN to int not throw an exception in Java?
body: <p>So I know the IEEE 754 specifies some special floating point values for values that are not real numbers.  In Java, casting those values to a primitive <code>int</code> does <strong>not</strong> throw an exception like I would have expected.  Instead we have the following:</p>
  
  <pre><code>int n;
  n = (int)Double.NaN; // n == 0
  n = (int)Double.POSITIVE_INFINITY; // n == Integer.MAX_VALUE
  n = (int)Double.NEGATIVE_INFINITY; // n == Integer.MIN_VALUE
  </code></pre>
  
  <p>What is the rationale for <strong>not</strong> throwing exceptions in these cases?  Is this an IEEE standard, or was it merely a choice by the designers of Java?  Are there bad consequences that I am unaware of if exceptions would be possible with such casts?</p>