I am new in java. I have a problem with Numeric literal. Here is my problem:
float rank = 1050.86F;
System.out.println(rank);
The output is: 1050.86
double rank1 = 1050.86D;
double rank2 = 1050.86F;
System.out.println(rank1);
System.out.println(rank2);
The output of rank1 is: 1050.86
The output of rank2 is: 1050.8599853515625
My question is:
(i)Why the output of rank1 and rank2 are different? and how I calculate that?
(ii) Why do I need to use L, D, F before semicolon? As we already used keyword double, int, so why we need to use L, D, F on variables?
Please Help me. I am new in programming.