From bacd7cb716a7fbbae022d0f9ecc7e65adb0d8e7b Mon Sep 17 00:00:00 2001 From: Miriam Amos Nihart Date: Wed, 21 Aug 1985 22:33:50 -0800 Subject: [PATCH] date and time created 85/08/21 15:33:50 by miriam SCCS-vsn: lib/libm/common_source/infnan.3 1.1 --- usr/src/lib/libm/common_source/infnan.3 | 98 +++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 usr/src/lib/libm/common_source/infnan.3 diff --git a/usr/src/lib/libm/common_source/infnan.3 b/usr/src/lib/libm/common_source/infnan.3 new file mode 100644 index 0000000000..13fe93e6e9 --- /dev/null +++ b/usr/src/lib/libm/common_source/infnan.3 @@ -0,0 +1,98 @@ +.TH INFNAN 3M "20 August 1985" +.UC 4 +.ds nn \fINaN\fR +.SH NAME +.nf +.ta \w'infnan \- 'u+1n +infnan \- signals invalid floating\-point operations on a VAX + TEMPORARY! ... Subject to Change. +.ta +.fi +.SH SYNOPSIS +.nf +.B #include +.PP +.B double infnan(iarg) +.B int iarg; +.SH DESCRIPTION +At some time in the future, some of the useful properties of +the Infinities and \*(nns in the IEEE standard 754 for Binary +Floating\-Point Arithmetic will be simulated in UNIX on the +DEC VAX by using its Reserved Operands. Meanwhile, the +Invalid, Overflow and Divide\-by\-Zero exceptions of the +IEEE standard are being approximated on a VAX by calls to a +procedure \fIinfnan\fR in appropriate places in \fIlibm\fR. When +better exception\-handling is implemented in UNIX, only +\fIinfnan\fR among the codes in \fIlibm\fR will have to be changed. +And users of \fIlibm\fR can design their own \fIinfnan\fR now to +insulate themselves from future changes. +.PP +Whenever an elementary function code in \fIlibm\fR has to +simulate one of the aforementioned IEEE exceptions, it calls +infnan(iarg) with an appropriate value of \fIiarg\fR. Then a +reserved operand fault stops computation. But \fIinfnan\fR could +be replaced by a function with the same name that returns +some plausible value, assigns an apt value to the global +variable \fIerrno\fR, and allows computation to resume. +Alternatively, the Reserved Operand Fault Handler could be +changed to respond by returning that plausible value etc. +instead of aborting. +.PP +In the table below, the first two columns show various +exceptions signaled by the IEEE standard, and the default +result it prescribes. The third column shows what value is +given to \fIiarg\fR by functions in \fIlibm\fR when they +invoke infnan(iarg) under analogous circumstances on a VAX. +Currently \fIinfnan\fR stops computation under all those +circumstances. The last two columns offer an alternative; +they suggest a setting for \fIerrno\fR and a value for a +revised \fIinfnan\fR to return. And a C program to +implement that suggestion follows. +.sp 0.5 +.RS +.nf +.ta \w'Div\-by\-0'u+2n +\w'+Infinity'u+1n +\w'+ERANGE'u+1n +\w'ERANGE or EDOM'u+4n +\w'+HUGE'u+1n +IEEE IEEE +Signal Default \fIiarg\fR \fIerrno\fR \fIinfnan\fR +.if t \ +\l'4i' +.if n \ +\l'5i' +Invalid \*(nn EDOM EDOM 0 +.if n \{\ +Overflow \(+-Infinity ERANGE ERANGE HUGE +Div\-by\-0 \(+-Infinity \(+-ERANGE ERANGE or EDOM \(+-HUGE \} +.if t \{\ +Overflow \(+-\(if ERANGE ERANGE HUGE +Div\-by\-0 \(+-\(if \(+-ERANGE ERANGE or EDOM \(+-HUGE \} +.sp 0.5 + (HUGE = 1.7e38 ... nearly 2.0**127) +.ta +.fi +.RE +.sp 0.5 +.PP +.nf +.ta \w'\fBextern int\fR'u+1n +\w'\fBdefault:\fR'u+1n +\w'\fB\-ERANGE:\fR'u+1n +\w'\fBerrno = ERANGE;\fR'u+1n +ALTERNATIVE \fIinfnan\fR:\fB +.sp 0.5 +#include +#include +extern int errno ; +double infnan(iarg) +int iarg ; +{ + switch(iarg) { + case \0ERANGE: errno = ERANGE; return(HUGE); + case \-ERANGE: errno = EDOM; return(\-HUGE); + default: errno = EDOM; return(0); + } +}\fR +.ta +.fi +.SH SEE ALSO +intro(3M), intro(2), signal(3). +.PP +ERANGE and EDOM are defined in . See intro(2) +for interpretations of EDOM and ERANGE from the operating +system's point of view. -- 2.20.1