Annotation of lucent/sys/src/libc/68020/nan.c, revision 1.1

1.1     ! root        1: #include <u.h>
        !             2: #include <libc.h>
        !             3: 
        !             4: #define        NANEXP  (2047<<20)
        !             5: #define        NANMASK (2047<<20)
        !             6: #define        NANSIGN (1<<31)
        !             7: 
        !             8: double
        !             9: NaN(void)
        !            10: {
        !            11:        union
        !            12:        {
        !            13:                double  d;
        !            14:                long    x[2];
        !            15:        } a;
        !            16: 
        !            17:        a.x[0] = NANEXP;
        !            18:        a.x[1] = 1;
        !            19:        return a.d;
        !            20: }
        !            21: 
        !            22: int
        !            23: isNaN(double d)
        !            24: {
        !            25:        union
        !            26:        {
        !            27:                double  d;
        !            28:                long    x[2];
        !            29:        } a;
        !            30: 
        !            31:        a.d = d;
        !            32:        if((a.x[0] & NANMASK) != NANEXP)
        !            33:                return 0;
        !            34:        return !isInf(d, 0);
        !            35: }
        !            36: 
        !            37: double
        !            38: Inf(int sign)
        !            39: {
        !            40:        union
        !            41:        {
        !            42:                double  d;
        !            43:                long    x[2];
        !            44:        } a;
        !            45: 
        !            46:        a.x[0] = NANEXP;
        !            47:        a.x[1] = 0;
        !            48:        if(sign < 0)
        !            49:                a.x[0] |= NANSIGN;
        !            50:        return a.d;
        !            51: }
        !            52: 
        !            53: int
        !            54: isInf(double d, int sign)
        !            55: {
        !            56:        union
        !            57:        {
        !            58:                double  d;
        !            59:                long    x[2];
        !            60:        } a;
        !            61: 
        !            62:        a.d = d;
        !            63:        if(a.x[1] != 0)
        !            64:                return 0;
        !            65:        if(a.x[0] == NANEXP)
        !            66:                return sign >= 0;
        !            67:        if(a.x[0] == (NANEXP|NANSIGN))
        !            68:                return sign <= 0;
        !            69:        return 0;
        !            70: }

unix.superglobalmegacorp.com

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