tanf.c revision ddc0e0b53c661f6e439e3b7072b3ef353eadb4af
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "libm.h"
extern const int _TBL_ipio2_inf[];
extern int __rem_pio2m(double *, double *, int, int, int, const int *);
extern int __swapRP(int);
#endif
static const double C[] = {
1.0,
4.46066928428959230679140546271810308098793029785e-0003,
4.92165316309189027066395283327437937259674072266e+0000,
-7.11410648161473480044492134766187518835067749023e-0001,
4.08549808374053391446523164631798863410949707031e+0000,
2.50411070398050927821032018982805311679840087891e+0000,
1.11492064560251158411574579076841473579406738281e+0001,
-1.50565540968422650891511693771462887525558471680e+0000,
-1.81484378878349295050043110677506774663925170898e+0000,
3.333335997532835641297409611782510896641e-0001,
2.999997598248363761541668282006867229939e+00,
0.636619772367581343075535, /* 2^ -1 * 1.45F306DC9C883 */
0.5,
1.570796326734125614166, /* 2^ 0 * 1.921FB54400000 */
6.077100506506192601475e-11, /* 2^-34 * 1.0B4611A626331 */
};
#define one C[0]
#define P0 C[1]
#define P1 C[2]
#define P2 C[3]
#define P3 C[4]
#define P4 C[5]
#define P5 C[6]
#define P6 C[7]
#define P7 C[8]
#define T0 C[9]
#define T1 C[10]
#define invpio2 C[11]
#define half C[12]
#define pio2_1 C[13]
#define pio2_t C[14]
float
tanf(float x)
{
double y, z, w;
float f;
volatile int i;
hx = *((int *)&x);
y = (double)x;
i = (int)y;
#ifdef lint
i = i;
#endif
return (x);
}
}
z = y * y;
}
if (hx > 0)
else
return ((float)(-one / z));
}
z = y * y;
return ((float)(-one / w));
}
int rp;
#endif
w = y * invpio2;
if (hx < 0)
n = (int)(w - half);
else
n = (int)(w + half);
if (rp != fp_extended)
#endif
} else {
if (ix >= 0x7f800000)
return (x / x); /* sin(Inf or NaN) is NaN */
if (hy < 0) {
y = -y;
n = -n;
}
}
f = ((n & 1) == 0)? (float)z : (float)(-one / z);
return (f);
}
z = y * y;
f = ((n & 1) == 0)? (float)w : (float)(-one / w);
return (f);
}