title: TypeCasting from double to long in JAVA
body: <pre><code>class test{
  public static void main(String... args){
      double d=5.637;
      System.out.println("double is:"+d);
      long a=(long)d;
      System.out.println("long is:"+a);
     }
  }
  </code></pre>
  
  <p>The output of above code is <code>long is : 5</code>, which is as expected.</p>
  
  <p>But when I ran the following code:</p>
  
  <pre><code>class test{
  public static void main(String... args){
       double d=12345678901234567890.637;
       System.out.println("double is:"+d);
       long a=(long)d;
       System.out.println("long is:"+a);
    }
  }
  </code></pre>
  
  <p>The output is not as expected. the the result is <code>long  is:9223372036854775807</code></p>
  
  <p>I want to ask why does it happen when I take huge number in double.</p>