Hi Jim,
Integral types (byte, short, int, long ) are represented in signed 2's complement integers. Whereas Floating point types float & double values are represented in single precision and double precision formats respectiely. These are IEEE 754 standards.
Which means a Floating type number(may be a double), whose integral part is within the float data type range, may loose its precision once you assign it to a float variable. That's why it is a narrowing coversion.
import java.io.*;
class Test{
public static void main(String a[]) {
float fa=3.03222222F;
double da=3.03222222;
System.out.println("Values fa: "+fa); // prints 3.0322223
System.out.println("Values da: "+da); // prints 3.03222222
}
}
I think this could be reason for not allowing floating type literals to be assigned to float variables.
Regards,
Phani.