machine eps related query
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sean Doherty
am 29 Dez. 2020
Beantwortet: Ameer Hamza
am 29 Dez. 2020
1 + eps > 1
ans =
logical
1
% as expcted
1 + eps
ans =
1.000000000000000
% unexpected, and indeed
1+2.5*eps
ans =
1.000000000000000
any help appreciated
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 29 Dez. 2020
It happens because of finite precision of double() precision datatype: https://en.wikipedia.org/wiki/Double-precision_floating-point_format. Also, because of the fact that MATLAB only prints 16 digits by default, the remaining digits after conversion are not shown (double datatype cannot store more than 16 digits accurately). Try the following
>> fprintf('%0.20f\n', 1+eps)
1.00000000000000022204
>> fprintf('%0.20f\n', 1+2.5*eps)
1.00000000000000044409
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion 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!