Borrar filtros
Borrar filtros

Matlab returns Inf for 10^1000.

11 visualizaciones (últimos 30 días)
David
David el 10 de Oct. de 2013
Respondida: John D'Errico el 10 de Oct. de 2013
Why is 10^1000 unrepresentable in Matlab?

Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Oct. de 2013
MATLAB uses IEEE 754 Double Precision Floating Point. The maximum representable value is approximately 1E+308
The File Exchange has an extended precision integer tool.
The Symbolic Toolbox represents values with potentially longer precision. I am not certain what the limit is; 10^10000 possibly, maybe higher.
  2 comentarios
David
David el 10 de Oct. de 2013
Is there a formula for calculating the largest storable value by a n bit long string? Like, for single it's 2^31 - 1. Or, have I been misinformed?
Roger Stafford
Roger Stafford el 10 de Oct. de 2013
Editada: Roger Stafford el 10 de Oct. de 2013
In IEEE 754 double precision floating point numbers the largest possible finite number representable is 2^1024*(1-2*(-53)) and is called 'realmax'. The total bit string which represents these numbers is 64 bits long with one bit for the sign, 11 bits for the exponent, and 53 bits, one of which is implicit ("hidden"), for the significand (mantissa).
(Corrected)

Iniciar sesión para comentar.

Más respuestas (2)

John D'Errico
John D'Errico el 10 de Oct. de 2013
As Per and Roger have explained, the issue is that a double only goes so far. Floating point numbers use a fixed number of bits to encode any number within reasonable limits. However, some numbers are just too big. For them, you need a tool in matlab that is designed to handle them. Thus
sym('10^1000')
ans =
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
My HPF can do it too.
hpf('1e1000',100)
ans =
1.e1000
As well as my vpi tool, or the enhanced version of that tool, vpij.
vpi(10)^1000
ans =
10000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000
So MATLAB CAN represent that number, but only if you use the proper data type.

per isakson
per isakson el 10 de Oct. de 2013
Editada: per isakson el 10 de Oct. de 2013
Because
>> realmax( 'double' )
ans =
1.7977e+308

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by