MATLAB: It’s a bug

bugfloating pointMATLAB

I discovered a potential bug and I want to report it:
Matlab R2018a windows 10
alfa=-0.0052+(61-1)*0.0001;
reasoning this is 0.0060-0.0052=0.0008=8e-04
so:
alfa2=8e-04;
isequal(alfa,alfa2)
ans
0
if you open alfa variable you can see:
8.000000000000004e-04
in fact if you round alfa:
alfa3=round(alfa,10);
isequal(alfa2,alfa3)
ans
1
That's all Thanks

Best Answer

It‘s called floating point comparison just search with the tag floating-point in this forum you will find lot of reasons
abs(alfa-alfa2)<1e-04
Related Question