Annotation of researchv9/cmd/cfront/libC/complex/abs.c, revision 1.1

1.1     ! root        1: 
        !             2: #include "complex.h"
        !             3: #include "const.h"
        !             4: 
        !             5: double abs(complex z)
        !             6: {
        !             7:        register double temp;
        !             8:        register double r = z.re;
        !             9:        register double i = z.im;
        !            10:        
        !            11:        if (r < 0) r = -r;
        !            12:        if (i == 0) return r;
        !            13: 
        !            14:        if (i < 0) i = -i;
        !            15:        if (r == 0) return i;
        !            16: 
        !            17:        if (i > r) { temp = r; r = i; i = temp; }
        !            18:        temp = i/r;
        !            19:        temp = r*sqrt(1.0 + temp*temp);  /*overflow!!*/
        !            20:        return temp;
        !            21: }
        !            22: 
        !            23: double norm(complex z)
        !            24: {
        !            25:        register double r = z.re;
        !            26:        register double i = z.im;
        !            27: 
        !            28: #define        SAFE 6.521908912666391000e+18  /* 0.5*sqrt(GREATEST)*/
        !            29: 
        !            30:        if (r<SAFE && i<SAFE) return r*r+i*i;
        !            31:        return GREATEST;
        !            32: }

unix.superglobalmegacorp.com

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