Browse Source

special-case more accurate answer for exp(1.0)

Jeff Bezanson 11 years ago
parent
commit
9bc257a323
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/e_exp.c

+ 5 - 0
src/e_exp.c

@@ -125,6 +125,11 @@ __ieee754_exp(double x)	/* default IEEE double exp */
 	    if(x < u_threshold) return twom1000*twom1000; /* underflow */
 	}
 
+        /* by pure bad luck, this implementation's error for x==1.0 is
+           unusually large, although still within 1 ulp. */
+        if (x == 1.0)
+            return 2.718281828459045235360;
+
     /* argument reduction */
 	if(hx > 0x3fd62e42) {		/* if  |x| > 0.5 ln2 */ 
 	    if(hx < 0x3FF0A2B2) {	/* and |x| < 1.5 ln2 */