A DESCRIPTION OF THE PROBLEM : Is there a special reason why a cast from a double bigger than Int.Max to an Integer is handled differently than a cast from a long bigger than Int.Max to an Integer? I am aware that this behaviour is described in the language specification, i.e., the resulting value will be Int.Max for the double cast and for the long cast the additional bits will be cut off. I am just wondering about the motivation for this difference. Wouldn't it make sense to handle both casts the same way? The following example illustrates the difference. System.out.println(((int)2147483648L)); System.out.println(((int)2147483648.0));
|