Annotation of researchv10dc/630/3binc/nan.h, revision 1.1

1.1     ! root        1: #ident "@(#)/usr/include/nan.h.sl 1.3 4.1 09/02/86 29438 AT&T-SF"
        !             2: /* Handling of Not_a_Number's (only in IEEE floating-point standard) */
        !             3: #if _IEEE
        !             4: typedef union 
        !             5: {
        !             6:          struct        
        !             7:         {
        !             8:            unsigned sign     : 1;
        !             9:            unsigned exponent :11;
        !            10:             unsigned bits:20;
        !            11:            unsigned fraction_low:32;
        !            12:          } inf_parts;
        !            13:         struct 
        !            14:         {
        !            15:            unsigned sign     : 1;
        !            16:             unsigned exponent :11;
        !            17:            unsigned qnan_bit : 1;
        !            18:            unsigned bits     :19;
        !            19:            unsigned fraction_low: 32;
        !            20:          } nan_parts;
        !            21:          double d;
        !            22: 
        !            23: } dnan; 
        !            24: 
        !            25:        /* IsNANorINF checks that exponent of double == 2047 *
        !            26:         * i.e. that number is a NaN or an infinity          */
        !            27:        
        !            28: #define IsNANorINF(X)  (((dnan *)&(X))->nan_parts.exponent == 0x7ff)
        !            29: 
        !            30:        /* IsINF must be used after IsNANorINF          *
        !            31:         * has checked the exponent                     */
        !            32: 
        !            33: #define IsINF(X)  (((dnan *)&(X))->inf_parts.bits == 0 &&  \
        !            34:                     ((dnan *)&(X))->inf_parts.fraction_low == 0)
        !            35: 
        !            36:        /* IsPosNAN and IsNegNAN can be used            *
        !            37:         * to check the sign of infinities too          */
        !            38: 
        !            39: #define IsPosNAN(X)  (((dnan *)&(X))->nan_parts.sign == 0)
        !            40: 
        !            41: #define IsNegNAN(X)  (((dnan *)&(X))->nan_parts.sign == 1)
        !            42: 
        !            43:        /* GETNaNPC gets the leftmost 32 bits           *       
        !            44:         * of the fraction part                         */
        !            45: 
        !            46: #define GETNaNPC(dval)   (((dnan *)&(dval))->inf_parts.bits << 12 | \
        !            47:                          ((dnan *)&(dval))->nan_parts.fraction_low>> 20) 
        !            48: 
        !            49: #define KILLFPE()       (void) kill(getpid(), 8)
        !            50: #define NaN(X)  (((dnan *)&(X))->nan_parts.exponent == 0x7ff)
        !            51: #define KILLNaN(X)      if (NaN(X)) KILLFPE()
        !            52: 
        !            53: #else
        !            54: 
        !            55: typedef double dnan;
        !            56: #define IsINF(X)   0
        !            57: #define IsPINF(X)  0
        !            58: #define IsNegNAN(X)  0
        !            59: #define IsPosNAN(X)  0
        !            60: #define IsNAN(X)   0
        !            61: #define GETNaNPC(X)   0L
        !            62: 
        !            63: #define NaN(X)  0
        !            64: #define KILLNaN(X)
        !            65: #endif

unix.superglobalmegacorp.com

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