Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news.harvard.edu!news2.near.net!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!univ-lille1.fr!ciril.fr!news.imag.fr!cosmos.imag.fr!dedieu
From: dedieu@imag.fr (Eric Dedieu)
Subject: Exception handling question
Message-ID: <1994Sep21.124147.4678@imag.fr>
Sender: news@imag.fr
Nntp-Posting-Host: cosmos
Organization: Institut Imag, Grenoble, France
Date: Wed, 21 Sep 1994 12:41:47 GMT
Lines: 41

I have written a macro to prevent normalisation to 0.0 of underflows, or
overflows to return infinity:

(defmacro with-root-float (&body body)
 `(restart-case
      (handler-bind
          ((floating-point-underflow
	      #'(lambda (c)
		  (declare (ignore c))
		  (invoke-restart 'normaliser)))
	   (floating-point-overflow
	      #'(lambda (c)
		  (declare (ignore c))
		  (invoke-restart 'plafonner))))
	,.body)
    (normaliser () LEAST-FLOAT)
    (plafonner () MOST-FLOAT)))

The problem is that I can only treat positive results. OK with exp, like

(defsubst exp$ (x)
  (the float
    (with-root-float
      (exp (the float x)))))

but for * or /, how can I do (save passing the signum of the result as a
parameter to the macro) ?

----
Note: I have looked to the "c" variable, which doesn't seem to give the
wanted information. Describing c instead of ignoring it, (exp$ -8000) yields:

#<Structure Floating-Point-Underflow 11926AE>
is a structure of type Floating-Point-Underflow.
It has 2 slots, with the following values:
 Lucid::Operands:  Nil
 Lucid::Operation: Lucid::|Fetch Hardware Internal Floating-Point Value|
-- 
Eric Dedieu  (Eric.Dedieu@imag.fr)
LIFIA - 46 av. Felix Viallet, 38031 Grenoble Cedex, France
Tel: 76 57 46 11  - Fax: 76 57 46 02  - Dom: 76 49 78 80
