s_sinf.c revision 97409
1194179Sed/* s_sinf.c -- float version of s_sin.c.
2194179Sed * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3194179Sed */
4194179Sed
5194179Sed/*
6194179Sed * ====================================================
7194179Sed * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8194179Sed *
9194179Sed * Developed at SunPro, a Sun Microsystems, Inc. business.
10194179Sed * Permission to use, copy, modify, and distribute this
11194179Sed * software is freely granted, provided that this notice
12194179Sed * is preserved.
13194179Sed * ====================================================
14194179Sed */
15194179Sed
16194179Sed#ifndef lint
17194179Sedstatic char rcsid[] = "$FreeBSD: head/lib/msun/src/s_sinf.c 97409 2002-05-28 17:51:46Z alfred $";
18194179Sed#endif
19194179Sed
20194179Sed#include "math.h"
21194179Sed#include "math_private.h"
22194179Sed
23194179Sed	float sinf(float x)
24194179Sed{
25194179Sed	float y[2],z=0.0;
26194179Sed	int32_t n, ix;
27194179Sed
28194179Sed	GET_FLOAT_WORD(ix,x);
29194179Sed
30194179Sed    /* |x| ~< pi/4 */
31194179Sed	ix &= 0x7fffffff;
32218893Sdim	if(ix <= 0x3f490fd8) return __kernel_sinf(x,z,0);
33218893Sdim
34249423Sdim    /* sin(Inf or NaN) is NaN */
35194179Sed	else if (ix>=0x7f800000) return x-x;
36194179Sed
37239462Sdim    /* argument reduction needed */
38239462Sdim	else {
39198092Srdivacky	    n = __ieee754_rem_pio2f(x,y);
40226633Sdim	    switch(n&3) {
41194179Sed		case 0: return  __kernel_sinf(y[0],y[1],1);
42198092Srdivacky		case 1: return  __kernel_cosf(y[0],y[1]);
43198092Srdivacky		case 2: return -__kernel_sinf(y[0],y[1],1);
44227737Sdim		default:
45243830Sdim			return -__kernel_cosf(y[0],y[1]);
46194179Sed	    }
47194179Sed	}
48218893Sdim}
49194179Sed