In my application, I am using float value to hold customer score. And as per the requirement, the score may have only 5 decimal digits before the points and three digits after the points.
For example : 99999.999
But, I did not understand the strange behavior while printing float values using sysout.
Refer sample code below for more details :
public class Test {
public static void main(String[] args) {
float f1 = 9999.999f;
System.out.println(f1);
float f2 = 99999.999f;
System.out.println(f2);
}
}
And the Output is :
9999.999
100000.0
Here, why the value "99999.999" got auto incremented to "100000.0" while doing using sysout ? And why the same thing was not happened while using value of four decimal digits before the point i.e "9999.999" ?
Any suggestion appreciated.