Please take a look at the following code.
CODE:
class Casting
{
public static void main(
String args[])
{
int i=0;
long l=0;
short s=0;
float f = Float.NaN;
float f1 = Float.POSITIVE_INFINITY;
float f2 = Float.NEGATIVE_INFINITY;
i = (int)f1;
l= (long)f1;
s= (short)f1;
System.out.println("the value in i is:" + i ); //It's printing the largest representable value of type int.
System.out.println("the value in l is:" + l); //It's printing the largest representable value of type long.
System.out.println("the value in s is:" + s); //It's printing -1
}
}
Why s value is not the largest representable value of type short.
Thanks.
[This message has been edited by sree (edited March 17, 2000).]