1e301-10^301 ~= 0 ?

4 visualizaciones (últimos 30 días)
Robin Lindström
Robin Lindström el 14 de Ag. de 2016
Respondida: Walter Roberson el 14 de Ag. de 2016
Why does 1e301-10^301 not equal zero in matlab, but 1e300-10^300 does?
1e301-10^301 is 1.18961352678223e+285.

Respuesta aceptada

Walter Roberson
Walter Roberson el 14 de Ag. de 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.

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 14 de Ag. de 2016

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by