about summary refs log tree commit diff
path: root/src/math/__rem_pio2_large.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2013-11-24 01:06:38 +0000
committerSzabolcs Nagy <nsz@port70.net>2013-11-24 01:06:38 +0000
commit3fdf94ec5101fab63d0e8196d3e557641a0e19e2 (patch)
treea8684dad2f216505e97263187b768013648146d0 /src/math/__rem_pio2_large.c
parent10c8b7148b918938d8e681c5801b913dd56cb7e4 (diff)
downloadmusl-3fdf94ec5101fab63d0e8196d3e557641a0e19e2.tar.gz
musl-3fdf94ec5101fab63d0e8196d3e557641a0e19e2.tar.xz
musl-3fdf94ec5101fab63d0e8196d3e557641a0e19e2.zip
math: clean up __rem_pio2
- remove the HAVE_EFFICIENT_IRINT case: fn is an exact integer, so
  it can be converted to int32_t a bit more efficiently than with a
  cast (the rounding mode change can be avoided), but musl does not
  support this case on any arch.
- __rem_pio2: use double_t where possible
- __rem_pio2f: use less assignments to avoid stores on i386
- use unsigned int bit manipulation (and union instead of macros)
- use hexfloat literals instead of named constants
Diffstat (limited to 'src/math/__rem_pio2_large.c')
-rw-r--r--src/math/__rem_pio2_large.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/math/__rem_pio2_large.c b/src/math/__rem_pio2_large.c
index bb2dc43f..958f28c2 100644
--- a/src/math/__rem_pio2_large.c
+++ b/src/math/__rem_pio2_large.c
@@ -270,10 +270,6 @@ static const double PIo2[] = {
   2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */
 };
 
-static const double
-two24  = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
-twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
-
 int __rem_pio2_large(double *x, double *y, int e0, int nx, int prec)
 {
 	int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
@@ -304,8 +300,8 @@ int __rem_pio2_large(double *x, double *y, int e0, int nx, int prec)
 recompute:
 	/* distill q[] into iq[] reversingly */
 	for (i=0,j=jz,z=q[jz]; j>0; i++,j--) {
-		fw    = (double)((int32_t)(twon24* z));
-		iq[i] = (int32_t)(z-two24*fw);
+		fw    = (double)(int32_t)(0x1p-24*z);
+		iq[i] = (int32_t)(z - 0x1p24*fw);
 		z     = q[j-1]+fw;
 	}
 
@@ -330,7 +326,7 @@ recompute:
 			if (carry == 0) {
 				if (j != 0) {
 					carry = 1;
-					iq[i] = 0x1000000- j;
+					iq[i] = 0x1000000 - j;
 				}
 			} else
 				iq[i] = 0xffffff - j;
@@ -378,9 +374,9 @@ recompute:
 		}
 	} else { /* break z into 24-bit if necessary */
 		z = scalbn(z,-q0);
-		if (z >= two24) {
-			fw = (double)((int32_t)(twon24*z));
-			iq[jz] = (int32_t)(z-two24*fw);
+		if (z >= 0x1p24) {
+			fw = (double)(int32_t)(0x1p-24*z);
+			iq[jz] = (int32_t)(z - 0x1p24*fw);
 			jz += 1;
 			q0 += 24;
 			iq[jz] = (int32_t)fw;
@@ -392,7 +388,7 @@ recompute:
 	fw = scalbn(1.0,q0);
 	for (i=jz; i>=0; i--) {
 		q[i] = fw*(double)iq[i];
-		fw *= twon24;
+		fw *= 0x1p-24;
 	}
 
 	/* compute PIo2[0,...,jp]*q[jz,...,0] */