problem with low infinite number
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ediff(8,35)
ans =
7.4525e+03
profit(8,35)
ans =
7.4525e+03
bu=minus(profit,Ediff);
bu(8,35)
ans =
1.8190e-12
Why does subtracting 2 equal numbers produce a very small number?
1 Kommentar
Antworten (2)
the cyclist
am 3 Mär. 2024
Bearbeitet: the cyclist
am 3 Mär. 2024
You can see that they are not quite equal:
load("matlab_Ediff.mat","Ediff");
load("matlab_profit.mat","profit");
fprintf("Ediff = %16.14f\n",Ediff(8,35))
fprintf("profit = %16.14f",profit(8,35))
0 Kommentare
John D'Errico
am 3 Mär. 2024
They only look the same, to 4 decimal places.
format short
x = 1.23456789;
y = 1.23456987;
[x,y]
They certainly look the same to me. But only if I don't look at their actual values, down to the last digits. If I subtract them of course, they are seen to be different.
x - y
Surely you would expect the difference to be non-zero, even though, when displayed as only 5 dignificant digits, they seem identical?
format long
[x,y]
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!