s_tanf.c revision 97413
1241844Seadler/* s_tanf.c -- float version of s_tan.c.
2239922Sgonzo * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3239922Sgonzo */
4239922Sgonzo
5239922Sgonzo/*
6239922Sgonzo * ====================================================
7239922Sgonzo * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8239922Sgonzo *
9239922Sgonzo * Developed at SunPro, a Sun Microsystems, Inc. business.
10239922Sgonzo * Permission to use, copy, modify, and distribute this
11239922Sgonzo * software is freely granted, provided that this notice
12239922Sgonzo * is preserved.
13239922Sgonzo * ====================================================
14239922Sgonzo */
15239922Sgonzo
16239922Sgonzo#ifndef lint
17239922Sgonzostatic char rcsid[] = "$FreeBSD: head/lib/msun/src/s_tanf.c 97413 2002-05-28 18:15:04Z alfred $";
18239922Sgonzo#endif
19239922Sgonzo
20239922Sgonzo#include "math.h"
21239922Sgonzo#include "math_private.h"
22239922Sgonzo
23239922Sgonzofloat
24239922Sgonzotanf(float x)
25239922Sgonzo{
26239922Sgonzo	float y[2],z=0.0;
27239922Sgonzo	int32_t n, ix;
28239922Sgonzo
29239922Sgonzo	GET_FLOAT_WORD(ix,x);
30239922Sgonzo
31239922Sgonzo    /* |x| ~< pi/4 */
32239922Sgonzo	ix &= 0x7fffffff;
33239922Sgonzo	if(ix <= 0x3f490fda) return __kernel_tanf(x,z,1);
34239922Sgonzo
35239922Sgonzo    /* tan(Inf or NaN) is NaN */
36239922Sgonzo	else if (ix>=0x7f800000) return x-x;		/* NaN */
37239922Sgonzo
38239922Sgonzo    /* argument reduction needed */
39239922Sgonzo	else {
40239922Sgonzo	    n = __ieee754_rem_pio2f(x,y);
41239922Sgonzo	    return __kernel_tanf(y[0],y[1],1-((n&1)<<1)); /*   1 -- n even
42239922Sgonzo							      -1 -- n odd */
43239922Sgonzo	}
44239922Sgonzo}
45239922Sgonzo