s_sinf.c revision 151620
12116Sjkh/* s_sinf.c -- float version of s_sin.c.
22116Sjkh * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
32116Sjkh */
42116Sjkh
52116Sjkh/*
62116Sjkh * ====================================================
72116Sjkh * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
82116Sjkh *
92116Sjkh * Developed at SunPro, a Sun Microsystems, Inc. business.
102116Sjkh * Permission to use, copy, modify, and distribute this
118870Srgrimes * software is freely granted, provided that this notice
122116Sjkh * is preserved.
132116Sjkh * ====================================================
142116Sjkh */
152116Sjkh
162116Sjkh#ifndef lint
1750476Speterstatic char rcsid[] = "$FreeBSD: head/lib/msun/src/s_sinf.c 151620 2005-10-24 14:08:36Z bde $";
182116Sjkh#endif
192116Sjkh
202116Sjkh#include "math.h"
212116Sjkh#include "math_private.h"
222116Sjkh
2397413Salfredfloat
2497413Salfredsinf(float x)
252116Sjkh{
262116Sjkh	float y[2],z=0.0;
272116Sjkh	int32_t n, ix;
282116Sjkh
292116Sjkh	GET_FLOAT_WORD(ix,x);
302116Sjkh
312116Sjkh    /* |x| ~< pi/4 */
322116Sjkh	ix &= 0x7fffffff;
33151620Sbde	if(ix <= 0x3f490fd8) {
34151620Sbde	    if(ix<0x39800000)			/* if x < 2**-12 */
35151620Sbde		if(((int)x)==0) return x;	/* generate inexact */
36151620Sbde	    return __kernel_sinf(x,z,0);
37151620Sbde	}
382116Sjkh
392116Sjkh    /* sin(Inf or NaN) is NaN */
402116Sjkh	else if (ix>=0x7f800000) return x-x;
412116Sjkh
422116Sjkh    /* argument reduction needed */
432116Sjkh	else {
442116Sjkh	    n = __ieee754_rem_pio2f(x,y);
452116Sjkh	    switch(n&3) {
462116Sjkh		case 0: return  __kernel_sinf(y[0],y[1],1);
472116Sjkh		case 1: return  __kernel_cosf(y[0],y[1]);
482116Sjkh		case 2: return -__kernel_sinf(y[0],y[1],1);
492116Sjkh		default:
502116Sjkh			return -__kernel_cosf(y[0],y[1]);
512116Sjkh	    }
522116Sjkh	}
532116Sjkh}
54