How can I calculate 10 ^ 400, without returning MATLAB "inf"?

I am dealing with very large numbers on the scale 10^500, 10^800. When I try to calculate 10^309, it returns inf.

>> 10^309
ans =
   Inf

I tested format long, it also returns inf.

>> format long 
>> 10^309
ans =
   Inf

I also checked the function vpa:

vpa(10^309,309)
ans =
    Inf

How can I calculate and use large numbers in my calculations? I cannot use the logarithm because I need all the numbers in very large numbers. those. I want MATLAB to return the following for10^308

vpa(10^308,308)
    ans =
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Can someone help me do this?

+4
source share
2 answers

vpa. , vpa:

>> A = vpa(10)^400

A =

1.0e400
+4

Variable Precision Integer Arithmetic, MATLAB. :

>>> A = vpi(17)^17 
ans = 
827240261886336764177

>>> 17 + A^17 
ans = 
39786732894291535047752038041559739510060813980024082 
30012867731573722066105737100731556603857745946047229 
53759676529121155309750944582301597489457676380805029 
59227566911971103003303064782118652210655457390045806 
99039190393572334521701109889855832341416056005878848 
49943142324389193616484809157960034059531548585473213 
36465170635561696613297503569949729314 

, .

+3

Source: https://habr.com/ru/post/1611851/


All Articles