mercredi 8 avril 2015

Subtracting digits in MATLAB [duplicate]


This question already has an answer here:




I'm trying to figure out this problem in MATLAB. Whenever i subtract the hundredths digits it does not compute but when i subtract the ten thousandths digits it does. I can't quite explain it properly but the code should show what i mean.



if 0.0110-0.0100 == 0.0010
fprintf('0.0110-0.0100 == 0.0010\n');
else
fprintf('0.0110-0.0100 is not equal to 0.0010\n');
end

if 0.0011-0.0001 == 0.0010
fprintf('0.0011-0.0001 == 0.0010\n');
else
fprintf('0.0011-0.0001 is not equal to 0.0010\n');
end


my output is:



0.0110-0.0100 is not equal to 0.0010
0.0011-0.0001 == 0.0010

Aucun commentaire:

Enregistrer un commentaire