Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cheating Underflow/Overflow Help Needed

1 view
Skip to first unread message

Samantha Skyler

unread,
May 25, 2002, 11:54:56 PM5/25/02
to
Hello all

I'm writing a subfunction that uses a lot of expt functions, so it
tends to crash my main program a lot with over/underflow errors.

I wanted to know if there is anyway to intercept this error and,
instead of crashing, have my subprogram return some value (-1, NIL,
whatever) whenever an error occurs so my main program can keep going.

Thanks a lot

-Samantha

Frank A. Adrian

unread,
May 26, 2002, 12:17:31 AM5/26/02
to
Samantha Skyler wrote:
> I wanted to know if there is anyway to intercept this error and,
> instead of crashing, have my subprogram return some value (-1, NIL,
> whatever) whenever an error occurs so my main program can keep going.

There are several. Look at section 9 of the Hyperspec
(http://www-2.cs.cmu.edu/Groups/AI/html/hyperspec/HyperSpec/Body/chap-9.html).

In addition, you might want to look at using numeric type other than
floating point. Rationals or rolling your own scaled integral type will
give you what you need without any possibility of overflow.

faa

Erik Naggum

unread,
May 26, 2002, 9:39:17 AM5/26/02
to
* Samantha Skyler

| I'm writing a subfunction that uses a lot of expt functions, so it
| tends to crash my main program a lot with over/underflow errors.

This is so common a request that IEEE 754 has support for not causing an
overflow or underflow, but instead return 0 and the largest possible
value (as opposed to an internal "infinity" value). This is not directly
supported by the Common Lisp standard, but you should find some support
for it in your implementation, or, if not, you should request it.
--
In a fight against something, the fight has value, victory has none.
In a fight for something, the fight is a loss, victory merely relief.

70 percent of American adults do not understand the scientific process.

0 new messages