From: David Simpson
Subject: Floating-Poing underflow
Date: 
Message-ID: <2qoq7g$40m@agate.berkeley.edu>
Is there anyway to avoid lisp returning a floating-point-underflow
error and have lisp return a value of zero instead.

E.g. exp( -2000 ) is an error... but shouldn't it just return 0.

Thanks in advance,

-Dave

---
David Simpson
········@cory.berkeley.edu
http://www-plateau.cs.berkeley.edu/people/davesimp/dave.html

From: Larry Hunter
Subject: Re: Floating-Poing underflow
Date: 
Message-ID: <HUNTER.94May10173146@work.nlm.nih.gov>
David Simpson writes:

   Is there anyway to avoid lisp returning a floating-point-underflow
   error and have lisp return a value of zero instead.

   E.g. exp( -2000 ) is an error... but shouldn't it just return 0.


Strange, Franz ACL 4.1 running on a SGI/Irix 4.0.5H, does return 0:

  USER(12): (exp -2000)
  0.0
  USER(13): (exp -2e3)
  0.0
  USER(14): (exp -2d3)
  0.0d0
  USER(15):

If your implementation signals an error, write a condition handler to catch
it, and have that return 0.

Larry
--
Lawrence Hunter, PhD.
National Library of Medicine
Bldg. 38A, MS-54
Bethesda. MD 20894 USA
tel: +1 (301) 496-9300
fax: +1 (301) 496-0673 
internet: ······@nlm.nih.gov
encryption: public key via RIPEM server or "finger ······@work.nlm.nih.gov"
From: Jim McDonald
Subject: Re: Floating-Poing underflow
Date: 
Message-ID: <1994May12.034052.23175@kestrel.edu>
In article <··········@agate.berkeley.edu>, ········@volga.EECS.Berkeley.EDU (David Simpson) writes:
|> Is there anyway to avoid lisp returning a floating-point-underflow
|> error and have lisp return a value of zero instead.
|> 
|> E.g. exp( -2000 ) is an error... but shouldn't it just return 0.
|> 
|> Thanks in advance,
|> 
|> -Dave
|> 
|> ---
|> David Simpson
|> ········@cory.berkeley.edu
|> http://www-plateau.cs.berkeley.edu/people/davesimp/dave.html

I don't have the documentation in front of me, but in Lucid Common Lisp
you can:

  (1) have the behavior you show, or 
  (2) establish a handler for this kind of error, or 
  (3) tell the hardware not to trap on this error.

I suspect you want the third option if speed is an issue.  There are macros
to create the appropriate context dynamically.   This is true for most of the
floating-point options (e.g., you might or might not want hardware 
generated NAN's for 0/0), but some are machine or O/S specific.
-- 
James McDonald
Kestrel Institute                       ········@kestrel.edu
3260 Hillview Ave.                      (415) 493-6871 ext. 339
Palo Alto, CA 94304                fax: (415) 424-1807