I have a for loop with decimal condition. If the loop iterates between 0.1 and 0.3 it is executed 2 times:
int count = 0;
for (double i=0.1d; i<=0.3d; i+=0.1d) {
count ++;
}
If the loop iterates between 0.2 and 0.4 it is executed 3 times:
int count = 0;
for (double i=0.2d; i<=0.4d; i+=0.1d) {
count ++;
}
I use System.out.println(count); to print out the result
Why is this happening? What am I missing?