Iulian Rosca
Iulian Rosca

Reputation: 1015

Matlab, exp function overflow

Can anyone suggest how can I find the largest value for which the function exp in Matlab doesn't overflow, and the smallest for which it overflows.
Thank You!

Upvotes: 0

Views: 573

Answers (2)

Drake
Drake

Reputation: 857

Trying

T = log(realmax('double'));

exp(T+255*eps)

gives

1.7977e+308

and

exp(T+256*eps)

gives

inf

Upvotes: 1

CatsLoveJazz
CatsLoveJazz

Reputation: 869

Try looking at the function realmin() or intmin(). These also have max partners for example:

realmin('double')
realmax('single')
intmin('int8')
intmax('int64')

This tells you the smallest value that that can be represented in the MATLAB type. Any number below this will be set to this min value for the given type.

Upvotes: 1

Related Questions