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

1.1       root        1: /*
                      2:  * libm/tan.c
                      3:  * Evaluate the tangent function.
                      4:  * (Hart 4245, 17.08)
                      5:  */
                      6: 
                      7: #include <math.h>
                      8: 
                      9: #if    EMU87
                     10: #include "emumath.h"
                     11: #endif
                     12: 
                     13: static readonly double tanntab[] ={
                     14:        -0.16045331195592187943926861e+05,
                     15:         0.12697548376580828837860720e+04,
                     16:        -0.17135185514886110932101000e+02,
                     17:         0.28208772971655103151400000e-01
                     18: };
                     19: static readonly double tanmtab[] ={
                     20:        -0.20429550186600697853114142e+05,
                     21:         0.58173599554655686739034190e+04,
                     22:        -0.18149310354089045993457500e+03,
                     23:         0.10000000000000000000000000e+01
                     24: };
                     25: 
                     26: double
                     27: tan(x) double x;
                     28: {
                     29:        double r;
                     30:        register int i, s;
                     31: 
                     32:        if ((x = modf(x/(2.0*PI), &r)) < 0.0) {
                     33:                x += 1.0;
                     34:                r -= 1.0;
                     35:        }
                     36:        i = 0;
                     37:        s = 0;
                     38:        if (x > 0.5)
                     39:                x -= 0.5;
                     40:        if (x > 0.25) {
                     41:                s = 1;
                     42:                x = 0.5 - x;
                     43:        }
                     44:        if (x > 0.125) {
                     45:                i = 1;
                     46:                x = 0.25 - x;
                     47:        }
                     48:        x *= 8.0;
                     49:        r = x * x;
                     50:        r = x * (_pol(r, tanntab, 4)/_pol(r, tanmtab, 4));
                     51:        if (i) {
                     52:                if (r < 1.0/HUGE_VAL) {
                     53:                        errno = ERANGE;
                     54:                        return HUGE_VAL;
                     55:                }
                     56:                r = 1/r;
                     57:        }
                     58:        return s ? -r : r;
                     59: }
                     60: 
                     61: /* end of libm/tan.c */

unix.superglobalmegacorp.com

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