Home | History | Annotate | Line # | Download | only in src
      1  1.1       jtc /* s_tanf.c -- float version of s_tan.c.
      2  1.1       jtc  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian (at) cygnus.com.
      3  1.1       jtc  */
      4  1.1       jtc 
      5  1.1       jtc /*
      6  1.1       jtc  * ====================================================
      7  1.1       jtc  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
      8  1.1       jtc  *
      9  1.1       jtc  * Developed at SunPro, a Sun Microsystems, Inc. business.
     10  1.1       jtc  * Permission to use, copy, modify, and distribute this
     11  1.6    simonb  * software is freely granted, provided that this notice
     12  1.1       jtc  * is preserved.
     13  1.1       jtc  * ====================================================
     14  1.1       jtc  */
     15  1.1       jtc 
     16  1.5     lukem #include <sys/cdefs.h>
     17  1.3       jtc #if defined(LIBM_SCCS) && !defined(lint)
     18  1.8  riastrad __RCSID("$NetBSD: s_tanf.c,v 1.8 2024/05/08 01:40:27 riastradh Exp $");
     19  1.1       jtc #endif
     20  1.1       jtc 
     21  1.8  riastrad #include "namespace.h"
     22  1.1       jtc #include "math.h"
     23  1.1       jtc #include "math_private.h"
     24  1.1       jtc 
     25  1.8  riastrad __weak_alias(tanf, _tanf)
     26  1.8  riastrad 
     27  1.7       wiz float
     28  1.7       wiz tanf(float x)
     29  1.1       jtc {
     30  1.1       jtc 	float y[2],z=0.0;
     31  1.2       jtc 	int32_t n, ix;
     32  1.1       jtc 
     33  1.1       jtc 	GET_FLOAT_WORD(ix,x);
     34  1.1       jtc 
     35  1.1       jtc     /* |x| ~< pi/4 */
     36  1.1       jtc 	ix &= 0x7fffffff;
     37  1.1       jtc 	if(ix <= 0x3f490fda) return __kernel_tanf(x,z,1);
     38  1.1       jtc 
     39  1.1       jtc     /* tan(Inf or NaN) is NaN */
     40  1.1       jtc 	else if (ix>=0x7f800000) return x-x;		/* NaN */
     41  1.1       jtc 
     42  1.1       jtc     /* argument reduction needed */
     43  1.1       jtc 	else {
     44  1.1       jtc 	    n = __ieee754_rem_pio2f(x,y);
     45  1.1       jtc 	    return __kernel_tanf(y[0],y[1],1-((n&1)<<1)); /*   1 -- n even
     46  1.1       jtc 							      -1 -- n odd */
     47  1.1       jtc 	}
     48  1.1       jtc }
     49