Back to index

glibc  2.9
s_tanf.c
Go to the documentation of this file.
00001 /* s_tanf.c -- float version of s_tan.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_tanf.c,v 1.4 1995/05/10 20:48:20 jtc Exp $";
00018 #endif
00019 
00020 #include "math.h"
00021 #include "math_private.h"
00022 
00023 #ifdef __STDC__
00024        float __tanf(float x)
00025 #else
00026        float __tanf(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 <= 0x3f490fda) return __kernel_tanf(x,z,1);
00038 
00039     /* tan(Inf or NaN) is NaN */
00040        else if (ix>=0x7f800000) return x-x;             /* NaN */
00041 
00042     /* argument reduction needed */
00043        else {
00044            n = __ieee754_rem_pio2f(x,y);
00045            return __kernel_tanf(y[0],y[1],1-((n&1)<<1)); /*   1 -- n even
00046                                                        -1 -- n odd */
00047        }
00048 }
00049 weak_alias (__tanf, tanf)