.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" @(#)infnan.3 6.5 (Berkeley) 4/19/91
.Nd signals invalid floating\-point operations on a
At some time in the future, some of the useful properties of
the Infinities and \*(Nas in the
Floating\-Point Arithmetic will be simulated in
by using its Reserved Operands. Meanwhile, the
Invalid, Overflow and Divide\-by\-Zero exceptions of the
standard are being approximated on a
better exception\-handling is implemented in
insulate themselves from future changes.
Whenever an elementary function code in
simulate one of the aforementioned
with an appropriate value of
reserved operand fault stops computation. But
be replaced by a function with the same name that returns
some plausible value, assigns an apt value to the global
and allows computation to resume.
Alternatively, the Reserved Operand Fault Handler could be
changed to respond by returning that plausible value, etc.
In the table below, the first two columns show various
exceptions signaled by the
standard, and the default
result it prescribes. The third column shows what value is
under analogous circumstances on a
stops computation under all those
circumstances. The last two columns offer an alternative;
they suggest a setting for
to return. And a C program to
implement that suggestion follows.
.Bd -filled -offset indent
.Bl -column "IEEE Signal" "IEEE Default" XXERANGE ERANGEXXorXXEDOM
.It IEEE Signal IEEE Default Ta
.It Overflow \(+-\*(If Ta
.It Div\-by\-0 \(+-Infinity Ta
.Dv \(+-ERANGE ERANGE or EDOM \(+-HUGE
.It ( Ns Dv HUGE No "= 1.7e38 ... nearly 2.0**127)"
.Bd -literal -offset indent
case \0ERANGE: errno = ERANGE; return(HUGE);
case \-ERANGE: errno = EDOM; return(\-HUGE);
default: errno = EDOM; return(0);