How to calculate exponent in matlab without getting inf?

The title says it all: I want to calculate the exponent in matlab with large numbers, but I get an overflow, and it just returns infinity.

>> 100^1000

ans =

   Inf

The last time I checked, 100 ^ 1000 is clearly less than infinity :)

+4
source share
3 answers

Working with 64-bit floating point arithmetic 100^1000is equal inf, because it is greater than the largest possible value. If a math text toolbar is available, use vpaor symto work with large numbers:

sym('100^1000')

or

vpa('100^1000')
+5
source

, , MATLAB. realmax . / , mantissa exponent base-10 representation, MATLAB. -

function [mantissa, base10_exponent] = base10_mantissa_exponent(base,exponent)

act_exp = exponent*log10(abs(base));
base10_exponent = floor(act_exp);
mantissa = power(10,act_exp - base10_exponent);

if rem(exponent,2)==1 && sign(base)==-1
    mantissa = -mantissa;
end

return;

MATLAB .

№ 1

base = -125.343;
exponent = 101;
usual_approach = base^exponent
[mantissa, base10_exponent] = base10_mantissa_exponent(base,exponent)

-

usual_approach =
 -8.0930e+211
mantissa =
   -8.0930
base10_exponent =
   211

№ 2 (, )

base = 100;
exponent = 1000;

-

usual_approach =
   Inf
mantissa =
     1
base10_exponent =
        2000
+5

High Precision Float,

a = hpf(100);
b = hpf(1000);
c = a^b;

c = 1.e2000. struct(c) , .

struct(c)

ans = 

NumberOfDigits: [64 4]
   DecimalBase: 4
          Base: 10000
       Numeric: 0
          Sign: 1
      Exponent: 2001
        Migits: [1000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
+1
source

All Articles