/* * tan(x) = sin(x) / cos(x) */ struct fpn * fpu_tan(struct fpemu *fe) { struct fpn x; struct fpn s; struct fpn *r; if (ISNAN(&fe->fe_f2)) return &fe->fe_f2; if (ISINF(&fe->fe_f2)) return fpu_newnan(fe); /* if x is +0/-0, return +0/-0 */ if (ISZERO(&fe->fe_f2)) return &fe->fe_f2; CPYFPN(&x, &fe->fe_f2); /* sin(x) */ CPYFPN(&fe->fe_f2, &x); r = fpu_sin(fe); CPYFPN(&s, r); /* cos(x) */ CPYFPN(&fe->fe_f2, &x); r = fpu_cos(fe); CPYFPN(&fe->fe_f2, r); CPYFPN(&fe->fe_f1, &s); r = fpu_div(fe); return r; }
/* undefined functions will result in a berp (panic) or whatever when called */ double sin( double ang ) { extern double fpu_sin(double); return fpu_sin(ang); }