Clear Filters
Clear Filters

Matlab returns Inf for 10^1000.

11 views (last 30 days)
David
David on 10 Oct 2013
Answered: John D'Errico on 10 Oct 2013
Why is 10^1000 unrepresentable in Matlab?

Accepted Answer

Walter Roberson
Walter Roberson on 10 Oct 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 Comments
David
David on 10 Oct 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 on 10 Oct 2013
Edited: Roger Stafford on 10 Oct 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)

Sign in to comment.

More Answers (2)

John D'Errico
John D'Errico on 10 Oct 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 on 10 Oct 2013
Edited: per isakson on 10 Oct 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!