MATLAB: Matlab can’t recognize the 0.06 in array 0.01:0.01:0.1

bugfloating pointnot a bug

Hi,
I executed below cods (attached photo) in Matlab 2018 and the answer is wrong . I was using methode ismember for two sample but the answer for 0.08 is true and the answer for 0.06 is false.
I would like to know , how can I fix this problem.
codes:
————————————————————————-
A = 0.01:0.01:0.1;
disp(A);
B= 0.06 ;
C= ismember(B,A);
disp("0.06 is " +C)
D= 0.08;
E = ismember(D,A);
disp("0.08 is " +E)
————————————————————————–
Thanks
Ali

Best Answer

Use ismembertol()
Also search with the tag floating point to know more.