Filter löschen
Filter löschen

Matlab returns Inf for 10^1000.

11 Ansichten (letzte 30 Tage)
David
David am 10 Okt. 2013
Beantwortet: John D'Errico am 10 Okt. 2013
Why is 10^1000 unrepresentable in Matlab?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 10 Okt. 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 Kommentare
David
David am 10 Okt. 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 am 10 Okt. 2013
Bearbeitet: Roger Stafford am 10 Okt. 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)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

John D'Errico
John D'Errico am 10 Okt. 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 am 10 Okt. 2013
Bearbeitet: per isakson am 10 Okt. 2013
Because
>> realmax( 'double' )
ans =
1.7977e+308

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by