Java.
Is there a difference in a way I initialize a variable:
float f = 100; //implies a cast from integer to float
or
float f = 100f; //simply a float initialization
Can the results be different?
Here I tried to do it with a very big floats, but looks like the loss of precision is the same.
float f1 = (float)2000000000;
float f2 = (float)2000000050;
float f3 = 2000000000f;
float f4 = 2000000050f;
System.out.println(f1 + " " + f2 + " " + (f1==f2) + " " + f3 + " " + f4 + " "+ (f3==f4) );
-> 2.0E9 2.0E9 true 2.0E9 2.0E9 true
Any difference with the doubles?