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.
*/
@@ -36,13 +37,11 @@
#include "libm.h"
#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)
{
@@ -50,31 +49,39 @@
double t[3], v[5];
int e0, i, nx, n, sign;
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 < 3; i++) {
t[i] = (double)((int)(z));
z = (z - (long double)t[i]) * two24l;
}
+
nx = 3;
- while (t[nx-1] == 0.0)
+
+ while (t[nx - 1] == 0.0)
nx--; /* omit trailing zeros */
+
n = __rem_pio2m(t, v, e0, nx, 2, _TBL_ipio2l_inf);
z = (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);
}