Back to index

glibc  2.9
s_sinf.c
Go to the documentation of this file.
00001 /* s_sinf.c -- float version of s_sin.c.
00002  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
00003  */
00004 
00005 /*
00006  * ====================================================
00007  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00008  *
00009  * Developed at SunPro, a Sun Microsystems, Inc. business.
00010  * Permission to use, copy, modify, and distribute this
00011  * software is freely granted, provided that this notice 
00012  * is preserved.
00013  * ====================================================
00014  */
00015 
00016 #if defined(LIBM_SCCS) && !defined(lint)
00017 static char rcsid[] = "$NetBSD: s_sinf.c,v 1.4 1995/05/10 20:48:16 jtc Exp $";
00018 #endif
00019 
00020 #include "math.h"
00021 #include "math_private.h"
00022 
00023 #ifdef __STDC__
00024        float __sinf(float x)
00025 #else
00026        float __sinf(x)
00027        float x;
00028 #endif
00029 {
00030        float y[2],z=0.0;
00031        int32_t n, ix;
00032 
00033        GET_FLOAT_WORD(ix,x);
00034 
00035     /* |x| ~< pi/4 */
00036        ix &= 0x7fffffff;
00037        if(ix <= 0x3f490fd8) return __kernel_sinf(x,z,0);
00038 
00039     /* sin(Inf or NaN) is NaN */
00040        else if (ix>=0x7f800000) return x-x;
00041 
00042     /* argument reduction needed */
00043        else {
00044            n = __ieee754_rem_pio2f(x,y);
00045            switch(n&3) {
00046               case 0: return  __kernel_sinf(y[0],y[1],1);
00047               case 1: return  __kernel_cosf(y[0],y[1]);
00048               case 2: return -__kernel_sinf(y[0],y[1],1);
00049               default:
00050                      return -__kernel_cosf(y[0],y[1]);
00051            }
00052        }
00053 }
00054 weak_alias (__sinf, sinf)