Annotation of researchv10no/cmd/lcc/etc/float.c, revision 1.1

1.1     ! root        1: #include <math.h>
        !             2: double ipow();
        !             3: 
        !             4: main()
        !             5: {
        !             6: #if mips || sun
        !             7:        flt(2,  -125,  128, 24, 0x34000000, 0x7f7fffff, 0x00800000);
        !             8:        dbl(2, -1021, 1024, 53, 0x3cb00000, 0x00000000, 0x7fefffff, 0xffffffff, 0x00100000, 0x00000000);
        !             9: #endif
        !            10: #ifdef vax
        !            11:        flt(2,  -127,  127, 24, 0x00003500, 0xffff7fff, 0x00000080);
        !            12:        dbl(2,  -127,  127, 56, 0x00002500, 0x00000000, 0xffff7fff, 0xffffffff, 0x00000080, 0x00000000);
        !            13: #endif
        !            14: }
        !            15: 
        !            16: dbl(b, emin, emax, p, eps, max, min)
        !            17: double eps, max, min;
        !            18: {
        !            19:        printf("#define DBL_DIG         %g\n", floor((p-1)*log10((double)b)+ispower10(b)));
        !            20:        printf("#define DBL_EPSILON     %.20e\n", eps);
        !            21:        printf("#define DBL_EPSILON     %.20e\n", ipow(b, 1-p));
        !            22:        printf("#define DBL_MANT_DIG    %d\n", p);
        !            23:        printf("#define DBL_MAX         %.20e\n", (1-ipow(b, -p))*ipow(b, emax-1)*b);
        !            24:        printf("#define DBL_MAX         %.20e\n", max);
        !            25:        printf("#define DBL_MAX_10_EXP  %g\n", floor(log10((1-ipow(b, -p))*ipow(b, emax-1)*b)));
        !            26:        printf("#define DBL_MAX_EXP     %d\n", emax);
        !            27:        printf("#define DBL_MIN         %.20e\n", ipow(b, emin-1));
        !            28:        printf("#define DBL_MIN         %.20e\n", min);
        !            29:        printf("#define DBL_MIN_10_EXP  %g\n", ceil(log10(ipow(b, emin-1))));
        !            30:        printf("#define DBL_MIN_EXP     %d\n", emin);
        !            31:        printf("\n");
        !            32: }
        !            33: 
        !            34: flt(b, emin, emax, p, eps, max, min)
        !            35: {
        !            36:        printf("#define FLT_DIG         %g\n", floor((p-1)*log10((double)b)+ispower10(b)));
        !            37:        printf("#define FLT_EPSILON     %.20e\n", *(float*)&eps);
        !            38:        printf("#define FLT_EPSILON     %.20e\n", ipow(b, 1-p));
        !            39:        printf("#define FLT_MANT_DIG    %d\n", p);
        !            40:        printf("#define FLT_MAX         %.20e\n", (1-ipow(b, -p))*ipow(b, emax-1)*b);
        !            41:        printf("#define FLT_MAX         %.20e\n", *(float*)&max);
        !            42:        printf("#define FLT_MAX_10_EXP  %g\n", floor(log10((1-ipow(b, -p))*ipow(b, emax-1)*b)));
        !            43:        printf("#define FLT_MAX_EXP     %d\n", emax);
        !            44:        printf("#define FLT_MIN         %.20e\n", *(float*)&min);
        !            45:        printf("#define FLT_MIN         %.20e\n", ipow(b, emin-1));
        !            46:        printf("#define FLT_MIN_10_EXP  %g\n", ceil(log10(ipow(b, emin-1))));
        !            47:        printf("#define FLT_MIN_EXP     %d\n", emin);
        !            48:        printf("\n");
        !            49: }
        !            50: 
        !            51: double ipow(x, n)
        !            52: {
        !            53:        double ac;
        !            54: 
        !            55:        if (n >= 0)
        !            56:                for (ac = 1; n > 0; n--)
        !            57:                        ac *= x;
        !            58:        else
        !            59:                for (ac = 1; n < 0; n++)
        !            60:                        ac /= x;
        !            61:        return ac;
        !            62: }
        !            63: 
        !            64: ispower10(x)
        !            65: {
        !            66:        double p;
        !            67: 
        !            68:        for (p = 1; p < x; p *= 10)
        !            69:                ;
        !            70:        return p == x;
        !            71: }

unix.superglobalmegacorp.com

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