How to compute an exponent in matlab without getting inf?

前端 未结 3 896

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

>> 100^1000

ans =
         


        
3条回答
  •  醉梦人生
    2021-01-06 02:52

    To deal with large numbers there is also the class High Precision Float, with which the result can be achieved by writing

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

    which gives c = 1.e2000. A call to struct(c) provides informations on how the number is internally stored.

    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]
    

提交回复
热议问题