Annotation of 43BSDReno/lib/libm/common_source/infnan.3, revision 1.1

1.1     ! root        1: .\" Copyright (c) 1985 Regents of the University of California.
        !             2: .\" All rights reserved.  The Berkeley software License Agreement
        !             3: .\" specifies the terms and conditions for redistribution.
        !             4: .\"
        !             5: .\"    @(#)infnan.3    6.4 (Berkeley) 5/27/86
        !             6: .\"
        !             7: .TH INFNAN 3M  "May 27, 1986"
        !             8: .UC 6
        !             9: .ds nn \fINaN\fR
        !            10: .SH NAME
        !            11: infnan \- signals invalid floating-point operations on a VAX (temporary)
        !            12: .SH SYNOPSIS
        !            13: .nf
        !            14: .B #include <math.h>
        !            15: .PP
        !            16: .B double infnan(iarg)
        !            17: .B int iarg;
        !            18: .SH DESCRIPTION
        !            19: At some time in the future, some of the useful properties of
        !            20: the Infinities and \*(nns in the IEEE standard 754 for Binary
        !            21: Floating\-Point Arithmetic will be simulated in UNIX on the
        !            22: DEC VAX by using its Reserved Operands.  Meanwhile, the
        !            23: Invalid, Overflow and Divide\-by\-Zero exceptions of the
        !            24: IEEE standard are being approximated on a VAX by calls to a
        !            25: procedure \fIinfnan\fR in appropriate places in \fIlibm\fR.  When
        !            26: better exception\-handling is implemented in UNIX, only
        !            27: \fIinfnan\fR among the codes in \fIlibm\fR will have to be changed.
        !            28: And users of \fIlibm\fR can design their own \fIinfnan\fR now to
        !            29: insulate themselves from future changes.
        !            30: .PP
        !            31: Whenever an elementary function code in \fIlibm\fR has to
        !            32: simulate one of the aforementioned IEEE exceptions, it calls
        !            33: infnan(iarg) with an appropriate value of \fIiarg\fR.  Then a
        !            34: reserved operand fault stops computation.  But \fIinfnan\fR could
        !            35: be replaced by a function with the same name that returns
        !            36: some plausible value, assigns an apt value to the global
        !            37: variable \fIerrno\fR, and allows computation to resume.
        !            38: Alternatively, the Reserved Operand Fault Handler could be
        !            39: changed to respond by returning that plausible value, etc.
        !            40: instead of aborting.
        !            41: .PP
        !            42: In the table below, the first two columns show various
        !            43: exceptions signaled by the IEEE standard, and the default
        !            44: result it prescribes.  The third column shows what value is
        !            45: given to \fIiarg\fR by functions in \fIlibm\fR when they
        !            46: invoke infnan(iarg) under analogous circumstances on a VAX.
        !            47: Currently \fIinfnan\fR stops computation under all those
        !            48: circumstances.  The last two columns offer an alternative;
        !            49: they suggest a setting for \fIerrno\fR and a value for a
        !            50: revised \fIinfnan\fR to return.  And a C program to
        !            51: implement that suggestion follows. 
        !            52: .sp 0.5
        !            53: .RS
        !            54: .nf
        !            55: .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
        !            56: IEEE   IEEE
        !            57: Signal Default \fIiarg\fR      \fIerrno\fR     \fIinfnan\fR
        !            58: .if t \{\
        !            59: .sp -0.5
        !            60: .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
        !            61: .tc \(ru
        !            62:        
        !            63: .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
        !            64: .tc \}
        !            65: .if n \
        !            66: \l'5i'
        !            67: Invalid        \*(nn   EDOM    EDOM    0
        !            68: .if n \{\
        !            69: Overflow       \(+-Infinity    ERANGE  ERANGE  HUGE
        !            70: Div\-by\-0     \(+-Infinity    \(+-ERANGE      ERANGE or EDOM  \(+-HUGE \}
        !            71: .if t \{\
        !            72: Overflow       \(+-\(if        ERANGE  ERANGE  HUGE
        !            73: Div\-by\-0     \(+-\(if        \(+-ERANGE      ERANGE or EDOM  \(+-HUGE \}
        !            74: .sp 0.5
        !            75:        (HUGE = 1.7e38 ... nearly  2.0**127)
        !            76: .ta
        !            77: .fi
        !            78: .RE
        !            79: .sp 0.5
        !            80: .PP
        !            81: .nf
        !            82: .ta \w'\fBextern int\fR'u+1n +\w'\fBdefault:\fR'u+1n +\w'\fB\-ERANGE:\fR'u+1n +\w'\fBerrno = ERANGE;\fR'u+1n
        !            83: ALTERNATIVE  \fIinfnan\fR:\fB
        !            84: .sp 0.5
        !            85: #include       <math.h>
        !            86: #include       <errno.h>
        !            87: extern int     errno ;
        !            88: double infnan(iarg)
        !            89: int    iarg ;
        !            90: {
        !            91:        switch(iarg) {
        !            92:        case    \0ERANGE:       errno = ERANGE; return(HUGE);
        !            93:        case    \-ERANGE:       errno = EDOM;   return(\-HUGE);
        !            94:        default:                errno = EDOM;   return(0);
        !            95:        }
        !            96: }\fR
        !            97: .ta
        !            98: .fi
        !            99: .SH SEE ALSO
        !           100: math(3M), intro(2), signal(3).
        !           101: .PP
        !           102: ERANGE and EDOM are defined in <errno.h>.  See intro(2)
        !           103: for explanation of EDOM and ERANGE.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.