Annotation of coherent/b/lib/libm/pow.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * libm/pow.c
                      3:  * Raise x to the power y.
                      4:  */
                      5: 
                      6: #include <math.h>
                      7: 
                      8: #if    EMU87
                      9: #include "emumath.h"
                     10: #endif
                     11: 
                     12: double
                     13: pow(x, y)
                     14: double x, y;
                     15: {
                     16:        double r;
                     17:        register unsigned s, i, e;
                     18: 
                     19:        s = 0;
                     20:        i = 0;
                     21:        if (x == 0.0) {
                     22:                if (y <= 0.0)
                     23:                        errno = EDOM;
                     24:                return 0.0;
                     25:        }
                     26:        if ((r = modf(y, &r)) < 0.0)
                     27:                r += 1.0;
                     28:        if (x < 0.0) {
                     29:                if (r != 0.0) {
                     30:                        errno = EDOM;
                     31:                        return 0.0;
                     32:                }
                     33:                x = -x;
                     34:                if (((int) y) & 1)
                     35:                        s = 1;
                     36:        }
                     37:        if (y < 0.0) {
                     38:                y = -y;
                     39:                i = 1;
                     40:        }
                     41:        if (r!=0.0 || y>16384.0)
                     42:                r = _two(y*log10(x)*LOG10B2);
                     43:        else {
                     44:                r = 1.0;
                     45:                for (e=y; e; e>>=1) {
                     46:                        if (e&01)
                     47:                                r *= x;
                     48:                        x *= x;
                     49:                }
                     50:        }
                     51:        if (i)
                     52:                r = 1/r;
                     53:        return s ? -r : r;
                     54: }
                     55: 
                     56: /* end of libm/pow.c */

unix.superglobalmegacorp.com

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