In article <··················@andrew.cmu.edu>,
Susan Slotnick <·········@CMU.EDU> wrote:
>I hope that this is the right place to post this query.
>
>I am porting an application from Allegro Common LISP to LUCID CL (don't
>ask..) On a calculation that worked fine in Allegro, I now get an
>overflow (or underflow) message, erratically.
>
>For example:
>
>-> temp
> 19333.351
> > (exp temp)
> >> Error: A condition of type FLOATING-POINT-OVERFLOW occurred.
>
> "Unknown Foreign Function": etc.
>
>The thing is, I don't always get the error! Sometimes I do the same
>thing and see:
>
>-> (exp temp)
>
> #<FLOAT :PLUS-INFINITY>
>
Hmmm ... I can't explain the ``unknown foreign function'' business.
Never seen it before. (What platform are you on?)
Onto the general problem. You have three choices:
1. Use the condition system.
> (handler-case
(exp 19333.351)
(lcl:floating-point-overflow ()
most-positive-double-float))
1.7976931348623158E308
2. Within a given dynamic extent turn off overflow traps:
> (lcl:with-floating-point-traps
('(division-by-zero floating-point-underflow)
'(floating-point-overflow floating-point-invalid-operation))
(exp 19333.351))
#<float :plus-infinity>
The work that LCL:WITH-FLOATING-POINT-TRAPS does isn't free, so avoid
it in any tight inner loops.
3. Turn off overflows indefinitely:
> (setf (lcl:enabled-floating-point-traps)
'(division-by-zero floating-point-underflow))
(division-by-zero floating-point-underflow)
> (exp 19333.351)
#<float :plus-infinity>
>
This is a very cheap solution.
Hope this helps.
-- Chris.
(··@lks.csi.com)