Print this page
11210 libm should be cstyle(1ONBLD) clean
@@ -20,10 +20,11 @@
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -33,22 +34,21 @@
* return the remainder of x rem pi/2 in y[0]+y[1] by calling __rem_pio2m
*/
#ifndef FDLIBM_BASED
#include "libm.h"
+
extern int __rem_pio2m(double *, double *, int, int, int, const int *);
#else /* FDLIBM_BASED */
#include "fdlibm.h"
#define __rem_pio2m __kernel_rem_pio2
#endif /* FDLIBM_BASED */
#include "longdouble.h"
extern const int _TBL_ipio2l_inf[];
-
-static const long double
- two24l = 16777216.0L,
+static const long double two24l = 16777216.0L,
pio4 = 0.7853981633974483096156608458198757210495L;
int
__rem_pio2l(long double x, long double *y)
{
@@ -57,32 +57,40 @@
int e0, i, nx, n, sign;
const int *ipio2;
sign = signbitl(x);
z = fabsl(x);
+
if (z <= pio4) {
y[0] = x;
y[1] = 0;
return (0);
}
+
e0 = ilogbl(z) - 23;
z = scalbnl(z, -e0);
+
for (i = 0; i < 5; i++) {
t[i] = (double)((int)(z));
z = (z - (long double)t[i]) * two24l;
}
+
nx = 5;
+
while (t[nx - 1] == 0.0)
nx--; /* skip zero term */
+
ipio2 = _TBL_ipio2l_inf;
n = __rem_pio2m(t, v, e0, nx, 3, (const int *)ipio2);
z = (long double)v[2] + (long double)v[1];
w = (long double)v[0];
y[0] = z + w;
y[1] = z - (y[0] - w);
+
if (sign != 0) {
y[0] = -y[0];
y[1] = -y[1];
return (-n);
}
+
return (n);
}