realmax on my machine is:
1.7977e+308
I know I have to write my code in a way to avoid long integer calculations, but is there
You may find vpa (variable- precision arithmetic) helpful:
R = vpa(A)
uses variable-precision arithmetic (VPA) to compute each element ofA
to at leastd
decimal digits of accuracy, whered
is the current setting ofdigits
.
R = vpa(A,d)
uses at leastd
significant (nonzero) digits, instead of the current setting ofdigits
.
Here's an example how to use it:
>> x = vpa('10^500/20')
ans =
5.0e498
Note that:
The output x
is of symbolic (sym) type. Of course, you shouldn't convert it to double
, because it would exceed realmax
:
>> double(x)
ans =
Inf
Use string input in order to avoid evaluating large input values as double
. For example, this doesn't work
>> vpa(10^500/20)
ans =
Inf
because 10^500
is evaluated as double
, giving inf
, and then is used as an input to vpa
.