Below is my matlab code snippet:
clear all;
x0=0.5;
x2=1.4;
h=0.1;
while(x0<x2)
x0=x0+0.1;
end
x0
There is no doubt that the result of x0
is 1.4
, what confused me is when I replace x2=1.4
to x2=0.8, 0.9, 1.0, 1.1, or 1.2
(anyone of them) the result becomes incorrect.
For example, x2=0.9
will makes the code generate x0=1.0
instead of x0=0.9
. And I find the fact that during the process with x0
increases to 0.9
then x0<x2
(0.9<0.9
) will yeild 1
(True) which is definitely wrong.
What's going on here?