Effacer les filtres
Effacer les filtres

1e301-10^301 ~= 0 ?

8 vues (au cours des 30 derniers jours)
Robin Lindström
Robin Lindström le 14 Août 2016
Why does 1e301-10^301 not equal zero in matlab, but 1e300-10^300 does?
1e301-10^301 is 1.18961352678223e+285.

Réponse acceptée

Walter Roberson
Walter Roberson le 14 Août 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.

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 14 Août 2016

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by