- At some time in the future, some of the useful properties of
- the Infinities and _\bN_\ba_\bNs 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 pro-
- cedure _\bi_\bn_\bf_\bn_\ba_\bn in appropriate places in _\bl_\bi_\bb_\bm. When better
- exception-handling is implemented in UNIX, only _\bi_\bn_\bf_\bn_\ba_\bn among
- the codes in _\bl_\bi_\bb_\bm will have to be changed. And users of
- _\bl_\bi_\bb_\bm can design their own _\bi_\bn_\bf_\bn_\ba_\bn now to insulate themselves
- from future changes.
-
- Whenever an elementary function code in _\bl_\bi_\bb_\bm has to simulate
- one of the aforementioned IEEE exceptions, it calls
- infnan(iarg) with an appropriate value of _\bi_\ba_\br_\bg. Then a
- reserved operand fault stops computation. But _\bi_\bn_\bf_\bn_\ba_\bn could
- be replaced by a function with the same name that returns
- some plausible value, assigns an apt value to the global
- variable _\be_\br_\br_\bn_\bo, and allows computation to resume. Alterna-
- tively, the Reserved Operand Fault Handler could be changed
- to respond by returning that plausible value, etc. instead
- of aborting.
-
- 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 _\bi_\ba_\br_\bg by functions in _\bl_\bi_\bb_\bm when they invoke
- infnan(iarg) under analogous circumstances on a VAX.
- Currently _\bi_\bn_\bf_\bn_\ba_\bn stops computation under all those cir-
- cumstances. The last two columns offer an alternative; they
- suggest a setting for _\be_\br_\br_\bn_\bo and a value for a revised _\bi_\bn_\bf_\bn_\ba_\bn
- to return. And a C program to implement that suggestion
- follows.
- IEEE IEEE
- Signal Default _\bi_\ba_\br_\bg _\be_\br_\br_\bn_\bo _\bi_\bn_\bf_\bn_\ba_\bn
- __________________________________________________
- Invalid _\bN_\ba_\bN EDOM EDOM 0
- Overflow +\b_Infinity ERANGE ERANGE HUGE
- Div-by-0 +\b_Infinity +\b_ERANGE ERANGE or EDOM +\b_HUGE
- (HUGE = 1.7e38 ... nearly 2.0**127)
-
-
-
-
-Printed 7/27/90 May 1
-
-
-
-
-
-
-INFNAN(3M) 1986 INFNAN(3M)
-
-
-
- ALTERNATIVE _\bi_\bn_\bf_\bn_\ba_\bn:
- #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<m\bma\bat\bth\bh.\b.h\bh>\b>
- #\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<e\ber\brr\brn\bno\bo.\b.h\bh>\b>
- e\bex\bxt\bte\ber\brn\bn i\bin\bnt\bt e\ber\brr\brn\bno\bo ;\b;
- d\bdo\bou\bub\bbl\ble\be i\bin\bnf\bfn\bna\ban\bn(\b(i\bia\bar\brg\bg)\b)
- i\bin\bnt\bt i\bia\bar\brg\bg ;\b;
- {\b{
- s\bsw\bwi\bit\btc\bch\bh(\b(i\bia\bar\brg\bg)\b) {\b{
- c\bca\bas\bse\be E\bER\bRA\bAN\bNG\bGE\bE:\b: e\ber\brr\brn\bno\bo =\b= E\bER\bRA\bAN\bNG\bGE\bE;\b; r\bre\bet\btu\bur\brn\bn(\b(H\bHU\bUG\bGE\bE)\b);\b;
- c\bca\bas\bse\be -\b-E\bER\bRA\bAN\bNG\bGE\bE:\b: e\ber\brr\brn\bno\bo =\b= E\bED\bDO\bOM\bM;\b; r\bre\bet\btu\bur\brn\bn(\b(-\b-H\bHU\bUG\bGE\bE)\b);\b;
- d\bde\bef\bfa\bau\bul\blt\bt:\b: e\ber\brr\brn\bno\bo =\b= E\bED\bDO\bOM\bM;\b; r\bre\bet\btu\bur\brn\bn(\b(0\b0)\b);\b;
- }\b}
- }\b}
+ At some time in the future, some of the useful properties of the Infini-
+ ties and _\bN_\ba_\bNs in the IEEE standard 754 for Binary Floating-Point Arith-
+ metic 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 proce-
+ dure i\bin\bnf\bfn\bna\ban\bn() in appropriate places in libm(3). When better excep-
+ tion-handling is implemented in UNIX, only i\bin\bnf\bfn\bna\ban\bn() among the codes in
+ libm will have to be changed. And users of libm can design their own
+ i\bin\bnf\bfn\bna\ban\bn() now to insulate themselves from future changes.
+
+ Whenever an elementary function code in libm has to simulate one of the
+ aforementioned IEEE exceptions, it calls i\bin\bnf\bfn\bna\ban\bn(_\bi_\ba_\br_\bg) with an appropriate
+ value of _\bi_\ba_\br_\bg. Then a reserved operand fault stops computation. But
+ i\bin\bnf\bfn\bna\ban\bn() could be replaced by a function with the same name that returns
+ some plausible value, assigns an apt value to the global variable _\be_\br_\br_\bn_\bo,
+ 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.
+
+ In the table below, the first two columns show various exceptions sig-
+ naled by the IEEE standard, and the default result it prescribes. The
+ third column shows what value is given to _\bi_\ba_\br_\bg by functions in libm when
+ they invoke i\bin\bnf\bfn\bna\ban\bn(_\bi_\ba_\br_\bg) under analogous circumstances on a VAX. Current-
+ ly i\bin\bnf\bfn\bna\ban\bn() stops computation under all those circumstances. The last
+ two columns offer an alternative; they suggest a setting for _\be_\br_\br_\bn_\bo and a
+ value for a revised i\bin\bnf\bfn\bna\ban\bn() to return. And a C program to implement
+ that suggestion follows.
+
+
+ IEEE Signal IEEE Default _\bi_\ba_\br_\bg _\be_\br_\br_\bn_\bo
+ i\bin\bnf\bfn\bna\ban\bn()
+ Invalid _\bN_\ba_\bN EDOM EDOM 0
+ Overflow +-infinity ERANGE ERANGE HUGE
+ Div-by-0 +-Infinity +-ERANGE ERANGE or
+ EDOM +-HUGE
+ (HUGE = 1.7e38 ... nearly 2.0**127)
+
+ ALTERNATIVE i\bin\bnf\bfn\bna\ban\bn():
+
+ #include <math.h>
+ #include <errno.h>
+ extern int errno ;
+ double infnan(iarg)
+ int iarg ;
+ {
+ switch(iarg) {
+ case ERANGE: errno = ERANGE; return(HUGE);
+ case -ERANGE: errno = EDOM; return(-HUGE);
+ default: errno = EDOM; return(0);
+ }
+ }