1INFNAN(3M)                                                          INFNAN(3M)
2
3
4

NAME

6       infnan - signals invalid floating-point operations on a VAX (temporary)
7

SYNOPSIS

9       #include <math.h>
10
11       double infnan(iarg)
12       int iarg;
13

DESCRIPTION

15       At  some  time  in  the  future,  some  of the useful properties of the
16       Infinities and NaNs in the IEEE standard 754 for Binary  Floating-Point
17       Arithmetic  will  be  simulated  in  UNIX  on  the DEC VAX by using its
18       Reserved Operands.  Meanwhile, the Invalid, Overflow and Divide-by-Zero
19       exceptions  of  the  IEEE  standard  are being approximated on a VAX by
20       calls to a procedure infnan in appropriate places in libm.  When better
21       exception-handling  is implemented in UNIX, only infnan among the codes
22       in libm will have to be changed.  And users of libm  can  design  their
23       own infnan now to insulate themselves from future changes.
24
25       Whenever an elementary function code in libm has to simulate one of the
26       aforementioned IEEE exceptions, it calls infnan(iarg) with an appropri‐
27       ate  value  of  iarg.  Then a reserved operand fault stops computation.
28       But infnan could be replaced by a function  with  the  same  name  that
29       returns  some plausible value, assigns an apt value to the global vari‐
30       able errno, and  allows  computation  to  resume.   Alternatively,  the
31       Reserved Operand Fault Handler could be changed to respond by returning
32       that plausible value, etc.  instead of aborting.
33
34       In the table below, the first two columns show various exceptions  sig‐
35       naled  by the IEEE standard, and the default result it prescribes.  The
36       third column shows what value is given to iarg  by  functions  in  libm
37       when  they  invoke infnan(iarg) under analogous circumstances on a VAX.
38       Currently infnan stops computation under all those circumstances.   The
39       last two columns offer an alternative; they suggest a setting for errno
40       and a value for a revised infnan to return.  And a C program to  imple‐
41       ment that suggestion follows.
42              IEEE      IEEE
43              Signal    Default   iarg    errno             infnan
44              __________________________________________________
45              Invalid   NaN       EDOM    EDOM              0
46              Overflow  ±Infinity ERANGE  ERANGE            HUGE
47              Div-by-0  ±Infinity ±ERANGE ERANGE or EDOM    ±HUGE
48                        (HUGE = 1.7e38 ... nearly  2.0**127)
49
50       ALTERNATIVE  infnan:
51       #include   <math.h>
52       #include   <errno.h>
53       extern int errno ;
54       double     infnan(iarg)
55       int        iarg ;
56       {
57                  switch(iarg) {
58                  case      ERANGE: errno = ERANGE; return(HUGE);
59                  case     -ERANGE: errno = EDOM;   return(-HUGE);
60                  default:          errno = EDOM;   return(0);
61                  }
62       }
63

SEE ALSO

65       math(3M), intro(2), signal(3).
66
67       ERANGE and EDOM are defined in <errno.h>.  See intro(2) for explanation
68       of EDOM and ERANGE.
69
70
71
724.3 Berkeley Distribution        May 27, 1986                       INFNAN(3M)
Impressum