Skip to content

Commit 4bcd8c3

Browse files
futogkeith-packard
authored andcommitted
libm/math: Update log1p FE_INEXACT code
Replace the code that is there to generate FE_INEXACT with __math_inexact.
1 parent bc276b6 commit 4bcd8c3

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

newlib/libm/common/s_log1p.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ Interface Definition (Issue 2).
120120
static const __float64
121121
ln2_hi = _F_64(6.93147180369123816490e-01), /* 3fe62e42 fee00000 */
122122
ln2_lo = _F_64(1.90821492927058770002e-10), /* 3dea39ef 35793c76 */
123-
two54 = _F_64(1.80143985094819840000e+16), /* 43500000 00000000 */
124123
Lp1 = _F_64(6.666666666666735130e-01), /* 3FE55555 55555593 */
125124
Lp2 = _F_64(3.999999999940941908e-01), /* 3FD99999 9997FA04 */
126125
Lp3 = _F_64(2.857142874366239149e-01), /* 3FD24924 94229359 */
@@ -149,11 +148,10 @@ log1p64(__float64 x)
149148
return __math_invalid (x); /* log1p(x<-1)=NaN */
150149
}
151150
if(ax<0x3e200000) { /* |x| < 2**-29 */
152-
if(two54+x>zero /* raise inexact */
153-
&&ax<0x3c900000) /* |x| < 2**-54 */
154-
return x;
151+
if(ax<0x3c900000) /* |x| < 2**-54 */
152+
return __math_inexact64(x);
155153
else
156-
return x - x*x*_F_64(0.5);
154+
return __math_inexact64(x - x*x*_F_64(0.5));
157155
}
158156
if(hx>0||hx<=((__int32_t)0xbfd2bec3)) {
159157
k=0;f=x;hu=1;} /* -0.2929<x<0.41422 */

newlib/libm/common/sf_log1p.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
static const float
2020
ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
2121
ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
22-
two25 = 3.355443200e+07, /* 0x4c000000 */
2322
Lp1 = 6.6666668653e-01, /* 3F2AAAAB */
2423
Lp2 = 4.0000000596e-01, /* 3ECCCCCD */
2524
Lp3 = 2.8571429849e-01, /* 3E924925 */
@@ -49,11 +48,10 @@ log1pf(float x)
4948
return __math_invalidf (x); /* log1p(x<-1)=NaN */
5049
}
5150
if(ax<0x31000000) { /* |x| < 2**-29 */
52-
if(two25+x>zero /* raise inexact */
53-
&&ax<0x24800000) /* |x| < 2**-54 */
54-
return x;
51+
if(ax<0x24800000) /* |x| < 2**-54 */
52+
return __math_inexactf(x);
5553
else
56-
return x - x*x*(float)0.5;
54+
return __math_inexactf(x - x*x*(float)0.5);
5755
}
5856
if(hx>0||hx<=((__int32_t)0xbe95f61f)) {
5957
k=0;f=x;hu=1;} /* -0.2929<x<0.41422 */

0 commit comments

Comments
 (0)