about summary refs log tree commit diff
path: root/src/math/expm1.c
diff options
context:
space:
mode:
authornsz <nsz@port70.net>2012-03-19 23:41:19 +0100
committernsz <nsz@port70.net>2012-03-19 23:41:19 +0100
commit0cbb65479147ecdaa664e88cc2a5a925f3de502f (patch)
tree7b6dc53fcec6497d55746d3cc47f167a20b7aa57 /src/math/expm1.c
parentb03255af77776703c8d48819e824d09f6f54ba86 (diff)
downloadmusl-0cbb65479147ecdaa664e88cc2a5a925f3de502f.tar.gz
musl-0cbb65479147ecdaa664e88cc2a5a925f3de502f.tar.xz
musl-0cbb65479147ecdaa664e88cc2a5a925f3de502f.zip
code cleanup of named constants
zero, one, two, half are replaced by const literals
The policy was to use the f suffix for float consts (1.0f),
but don't use suffix for long double consts (these consts
can be exactly represented as double).
Diffstat (limited to 'src/math/expm1.c')
-rw-r--r--src/math/expm1.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/math/expm1.c b/src/math/expm1.c
index ffa82264..f8f32c46 100644
--- a/src/math/expm1.c
+++ b/src/math/expm1.c
@@ -107,7 +107,6 @@
 #include "libm.h"
 
 static const double
-one         = 1.0,
 huge        = 1.0e+300,
 tiny        = 1.0e-300,
 o_threshold = 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
@@ -148,7 +147,7 @@ double expm1(double x)
 		if (xsb != 0) { /* x < -56*ln2, return -1.0 with inexact */
 			/* raise inexact */
 			if(x+tiny<0.0)
-				return tiny-one;  /* return -1 */
+				return tiny-1.0;  /* return -1 */
 		}
 	}
 
@@ -182,7 +181,7 @@ double expm1(double x)
 	/* x is now in primary range */
 	hfx = 0.5*x;
 	hxs = x*hfx;
-	r1 = one+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5))));
+	r1 = 1.0+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5))));
 	t  = 3.0-r1*hfx;
 	e  = hxs*((r1-t)/(6.0 - x*t));
 	if (k == 0)   /* c is 0 */
@@ -195,17 +194,17 @@ double expm1(double x)
 	if (k == 1) {
 		if (x < -0.25)
 			return -2.0*(e-(x+0.5));
-		return one+2.0*(x-e);
+		return 1.0+2.0*(x-e);
 	}
 	if (k <= -2 || k > 56) {  /* suffice to return exp(x)-1 */
-		y = one - (e-x);
+		y = 1.0 - (e-x);
 		if (k == 1024)
 			y = y*2.0*0x1p1023;
 		else
 			y = y*twopk;
-		return y - one;
+		return y - 1.0;
 	}
-	t = one;
+	t = 1.0;
 	if (k < 20) {
 		SET_HIGH_WORD(t, 0x3ff00000 - (0x200000>>k));  /* t=1-2^-k */
 		y = t-(e-x);
@@ -213,7 +212,7 @@ double expm1(double x)
 	} else {
 		SET_HIGH_WORD(t, ((0x3ff-k)<<20));  /* 2^-k */
 		y = x-(e+t);
-		y += one;
+		y += 1.0;
 		y = y*twopk;
 	}
 	return y;