Filter löschen
Filter löschen

1e301-10^301 ~= 0 ?

8 Ansichten (letzte 30 Tage)
Robin Lindström
Robin Lindström am 14 Aug. 2016
Beantwortet: Walter Roberson am 14 Aug. 2016
Why does 1e301-10^301 not equal zero in matlab, but 1e300-10^300 does?
1e301-10^301 is 1.18961352678223e+285.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 14 Aug. 2016
1e301 is computed entirely at parse time, as a double precision number.
10^301 involves computing 10 and 301 at parse time, each as double precision numbers, and then computing the one to the power of the other at run time, resulting in a double precision number. As this is a floating point calculation, it is subject to standard floating point roundoff .
1e301 comes out as the first representable double precision number greater than 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 and 10^301 is one bit different, coming out as the last representable double precision number less than 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 . 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 itself is not exactly representable in double precision.

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 14 Aug. 2016

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by