I want a create a array of values with a interval of 0.2 I used the code :
public class TrialCode {
public static void main(String[] args) {
float a = -1.0f, b = 0.2f;
for (int i = 0; i <10; i++) {
a = a + b;
System.out.println(a);
}
}
}
Now the output that i am getting is :
-0.8
-0.6
-0.40000004
-0.20000003
-2.9802322E-8
0.19999997
0.39999998
0.59999996
0.79999995
0.99999994
whereas the output I want is
-0.8, -0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6, 0.8, 1.0
What should I do ?