Annotation of coherent/b/bin/as/_pow10.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * C general utilities library internals.
        !             3:  * _pow10()
        !             4:  * Compute 10.0^n.
        !             5:  */
        !             6: 
        !             7: /*
        !             8:  * There are lots of ways to do this, with varying accuracy and speed.
        !             9:  * Using recursion on all negative exponents eliminates the divide
        !            10:  * but introduces greater roundoff errors.
        !            11:  */
        !            12: 
        !            13: static double powtab[] = {
        !            14:        1e-16,  1e-15,  1e-14,  1e-13,  1e-12,  1e-11,  1e-10,  1e-9,
        !            15:        1e-8,   1e-7,   1e-6,   1e-5,   1e-4,   1e-3,   1e-2,   1e-1,
        !            16:        1e0,
        !            17:        1e1,    1e2,    1e3,    1e4,    1e5,    1e6,    1e7,    1e8,
        !            18:        1e9,    1e10,   1e11,   1e12,   1e13,   1e14,   1e15,   1e16
        !            19: };
        !            20: 
        !            21: double
        !            22: _pow10(exp) register int exp;
        !            23: {
        !            24: 
        !            25:        if (exp < -16)
        !            26:                return (1.0/_pow10(-exp));
        !            27:        else if (exp <= 16)
        !            28:                return (powtab[exp+16]);
        !            29:        else if (exp <= 64)
        !            30:                return (1e16 * _pow10(exp - 16));
        !            31:        else
        !            32:                return (1e64 * _pow10(exp - 64));
        !            33: }

unix.superglobalmegacorp.com

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