floating-point exceptions

Deb Ryan deb at kea.wpd.sgi.com
Wed Nov 29 11:40:12 AEST 1989


Here is a short overview of the trap handler package we plan to provide 
in the next release:

caveat:  I should not be making promises -but all the work has been done.

(Edited from the man page)


Background:

  The MIPS floating-point accelerator may raise floating-point exceptions 
  due to five conditions: overflow, underflow, divide by zero, inexact result 
  or invalid operand (e.g. infinity).  Usually these conditions are masked, 
  and do not cause a floating-point exception. Instead,
  a default value is substituted for the result of the operation,
  and the program continues silently.  This event may be intercepted
  by causing an exception to be raised.  Once an exception is raised,
  the specific conditions which caused the exception may be 
  determined, and more appropriate action taken.

Our solution:

  The floating point library provides two methods to unmask and handle
  these conditions: a subroutine interface, and an environment variable.
  The environment variable requires no change to user code.

  Both methods provide a mechanism for unmasking each condition
  except inexact result, for handling and classifying exceptions arising 
  from them, and for substituting either a default value or a chosen one.
  They also provide mechanisms to count, trace, exit or abort on enabled
  exceptions.  

  If more control is required, the subroutine interface provides the ability 
  to call a user written routine.
  
  The environment variable is supported for Fortran, C and Pascal.
  The subroutine interface is supported for C and Fortran.

Limitations:
  
  Some math library routines, like sqrt, are written in software and do
  not yet conform to IEEE standards.  As a result, the square root of a 
  negative number, for example, will produce Nan and not get caught by the trap
  handler until used in user code.

--

					-Deb
					 deb at sgi.com
 					 Deborah Caruso @ Silicon Graphics



More information about the Comp.sys.sgi mailing list