I have this code:
while (x < 10.0) {
x += y;
}
If x
and y
are floating point numbers, apparently if you add them the loop will continue infinitely. I don't understand how it wont pass 10. It seems impossible to not pass ten but it doesn't according to my text book.
Why is that? Is it because of the rounding that happens with floating points? Or am I missing something?
Edit: x
and y
are strictly postive by the way