Пример #1
0
void
sincosl(long double x, long double *s, long double *c) {
	long double y[2], z = 0.0L;
	int n, ix;

	ix = *(int *) &x;	/* High word of x */

	/* |x| ~< pi/4 */
	ix &= 0x7fffffff;
	if (ix <= 0x3ffe9220)
		*s = __k_sincosl(x, z, c);
	else if (ix >= 0x7fff0000)
		*s = *c = x - x;	/* trig(Inf or NaN) is NaN */
	else {			/* argument reduction needed */
		n = __rem_pio2l(x, y);
		switch (n & 3) {
		case 0:
			*s = __k_sincosl(y[0], y[1], c);
			break;
		case 1:
			*c = -__k_sincosl(y[0], y[1], s);
			break;
		case 2:
			*s = -__k_sincosl(y[0], y[1], c);
			*c = -*c;
			break;
		case 3:
			*c = __k_sincosl(y[0], y[1], s);
			*s = -*s;
			break;
		}
	}
}
Пример #2
0
void
sincosl(long double x, long double *s, long double *c) {
	long double y[2], z = 0.0L;
	int n, ix;
#if defined(__i386) || defined(__amd64)
	int *px = (int *) &x;
#endif

	/* trig(Inf or NaN) is NaN */
	if (!finitel(x)) {
		*s = *c = x - x;
		return;
	}

	/* High word of x. */
#if defined(__i386) || defined(__amd64)
	XTOI(px, ix);
#else
	ix = *(int *) &x;
#endif

	/* |x| ~< pi/4 */
	ix &= 0x7fffffff;
	if (ix <= 0x3ffe9220)
		*s = __k_sincosl(x, z, c);

	/* argument reduction needed */
	else {
		n = __rem_pio2l(x, y);
		switch (n & 3) {
		case 0:
			*s = __k_sincosl(y[0], y[1], c);
			break;
		case 1:
			*c = -__k_sincosl(y[0], y[1], s);
			break;
		case 2:
			*s = -__k_sincosl(y[0], y[1], c);
			*c = -*c;
			break;
		case 3:
			*c = __k_sincosl(y[0], y[1], s);
			*s = -*s;
		}
	}
}