long by default taken as int and float as double
Hello Sir,
I could not assign a value more than 2,147,483,647 to a variable of type long.
long longvar = 2,147,483,648;
I get the compile error as:
MyDataType.java:17: error: integer number too large: 2147483648
long longvar = 2147483648;/*-9,223,372,036,854,775,808 to 9,223,372,03
6,854,775,807*/
Similarly when assign 4.5 to variable of type float
float floatvar = 4.5;
I get the following compile error:-
MyDataType.java:18: error: possible loss of precision
float floatvar = 4.5;
^
required: float
found: double
1 error
I tried even type casting. It still didn't work. Could you please help.