Cannot subtract number of order smaller then e-4 from variable
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dominik Stolfa
am 26 Nov. 2024
Kommentiert: Dominik Stolfa
am 26 Nov. 2024
a=0.1; a=a-1e-5 gives result a=0.1000
0 Kommentare
Akzeptierte Antwort
Torsten
am 26 Nov. 2024
Bearbeitet: Torsten
am 26 Nov. 2024
It's just a question of how the numbers are displayed.
Internally, the precision of computing is much higher.
format long % Use display format long
a = 0.1;
a = a - 1e-5
format short
a
3 Kommentare
Walter Roberson
am 26 Nov. 2024
Bearbeitet: Walter Roberson
am 26 Nov. 2024
format long % Use display format long
a = 0.1;
fprintf('%.999g\n', a)
a = a - 1e-5
fprintf('%.999g\n', a)
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!