title: Java type casting - float (and long) to int
body: <p>I am trying to understand the type casting in Java. I have read that  <code>long</code> is converted to <code>int</code> by using reduced modulo by range of <code>int</code> and <code>float</code> is converted to <code>int</code> by removing the fractional part.
  I tried the following code.</p>
  
  <pre><code>class test
  {
      public static void main(String arf[])
      {
          System.out.println((int)2147483648.0);
          System.out.println((int)2147483648L);
      }
  }
  </code></pre>
  
  <p>...where 2147483647 is the maximum value of <code>int</code>.</p>
  
  <p>The output is:</p>
  
  <pre><code>2147483647
  -2147483648
  </code></pre>
  
  <p>When <code>float</code> is converted to <code>int</code> its fractional part is removed. So, <code>(int)2147483648.0</code> should also equal to <code>-2147483648</code>.</p>
  
  <p>Can anyone explain to me why <code>2147483648.0</code> is cast to <code>2147483647</code>?</p>