4.4BSD/usr/share/man/cat3/infnan.0

Compare this file to the similar file:
Show the results in this format:

INFNAN(3)                   BSD Programmer's Manual                  INFNAN(3)

NNAAMMEE
     iinnffnnaann - signals invalid floating-point operations on a VAX (temporary)

SSYYNNOOPPSSIISS
     ##iinncclluuddee <<mmaatthh..hh>>

     _d_o_u_b_l_e
     iinnffnnaann(_i_n_t _i_a_r_g);

DDEESSCCRRIIPPTTIIOONN
     At some time in the future, some of the useful properties of the Infini-
     ties and _N_a_Ns 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 iinnffnnaann() in appropriate places in libm(3).  When better excep-
     tion-handling is implemented in UNIX, only iinnffnnaann() among the codes in
     libm will have to be changed.  And users of libm can design their own
     iinnffnnaann() 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 iinnffnnaann(_i_a_r_g) with an appropriate
     value of _i_a_r_g. Then a reserved operand fault stops computation.  But
     iinnffnnaann() could be replaced by a function with the same name that returns
     some plausible value, assigns an apt value to the global variable _e_r_r_n_o,
     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 _i_a_r_g by functions in libm when
     they invoke iinnffnnaann(_i_a_r_g) under analogous circumstances on a VAX. Current-
     ly iinnffnnaann() stops computation under all those circumstances.  The last
     two columns offer an alternative; they suggest a setting for _e_r_r_n_o and a
     value for a revised iinnffnnaann() to return.  And a C program to implement
     that suggestion follows.


           IEEE Signal    IEEE Default    _i_a_r_g           _e_r_r_n_o
                                                   iinnffnnaann()
           Invalid        _N_a_N             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 iinnffnnaann():

           #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);
                   }
           }

SSEEEE AALLSSOO
     math(3),  intro(2),  signal(3).

     ERANGE and EDOM are defined in <_e_r_r_n_o_._h>. (See intro(2) for explanation
     of EDOM and ERANGE.)

HHIISSTTOORRYY
     The iinnffnnaann() function appeared in 4.3BSD.

4.3 Berkeley Distribution        June 4, 1993                                2