Re: Wow. exp() difficulties... [message #9606 is a reply to message #9601] |
Thu, 24 July 1997 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
lady of the elves writes:
> I've encountered a really interesting--though annoying--problem. I'm
> trying to use exp(a), where a>88 or so. My calculator can do it...the
> program can't. It gives me a "floating underflow" error.
>
> Can anyone give me more information on how to work this out? I haven't
> yet figured out long numbers...nor how they differ from floating point.
> I don't know if these uncertainties relate, but all of my numbers are
> floating point.
>
> Is it just that the language can't handle the numbers? e^89=4.4*10^38;
> it's rather large--but is it just that it can't handle the size? Or the
> precision? Is it that I need to know more about long numbers?
I am no expert in this area, but I think the problem here is with
precision. e^89 is just simply too large to be represented adequately
as a floating point number (4 bytes). You need more bits. The problem
can be eliminated by casting your floating values to doubles. For
example,
this works:
a = 89.0
Print, EXP(Double(a))
4.4896128e+038
> What *is* a floating underflow?
In this case, it is a number that is so large it begins
to appear small. It's, er, a mystical thing. :-)
Cheers,
David
------------------------------------------------------------ -
David Fanning, Ph.D.
Fanning Software Consulting
Customizable IDL Programming Courses
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
IDL 5 Reports: http://www.dfanning.com/documents/anomaly5.html
|
|
|