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
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
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.