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);
}
}
The output of above code is long is : 5
, which is as expected.
But when I ran the following 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);
}
}
The output is not as expected. the the result is long is:9223372036854775807
I want to ask why does it happen when I take huge number in double.