@@ -112,7 +112,6 @@ ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
112
112
113
113
static double zero = 0.0 ;
114
114
115
- ATTRIBUTE_NO_UBSAN
116
115
static double __ieee754_log (double x) {
117
116
double hfsq,f,s,z,R,w,t1,t2,dk;
118
117
int k,hx,i,j;
@@ -126,8 +125,8 @@ static double __ieee754_log(double x) {
126
125
k=0 ;
127
126
if (hx < 0x00100000 ) { /* x < 2**-1022 */
128
127
if (((hx&0x7fffffff )|lx)==0 )
129
- return -two54/zero ; /* log(+-0)=-inf */
130
- if (hx<0 ) return (x-x)/zero ; /* log(-#) = NaN */
128
+ return -std::numeric_limits< double >:: infinity () ; /* log(+-0)=-inf */
129
+ if (hx<0 ) return std::numeric_limits< double >:: quiet_NaN () ; /* log(-#) = NaN */
131
130
k -= 54 ; x *= two54; /* subnormal number, scale up x */
132
131
hx = high (x); /* high word of x */
133
132
}
@@ -209,7 +208,6 @@ ivln10 = 4.34294481903251816668e-01, /* 0x3FDBCB7B, 0x1526E50E */
209
208
log10_2hi = 3.01029995663611771306e-01 , /* 0x3FD34413, 0x509F6000 */
210
209
log10_2lo = 3.69423907715893078616e-13 ; /* 0x3D59FEF3, 0x11F12B36 */
211
210
212
- ATTRIBUTE_NO_UBSAN
213
211
static double __ieee754_log10 (double x) {
214
212
double y,z;
215
213
int i,k,hx;
@@ -223,8 +221,8 @@ static double __ieee754_log10(double x) {
223
221
k=0 ;
224
222
if (hx < 0x00100000 ) { /* x < 2**-1022 */
225
223
if (((hx&0x7fffffff )|lx)==0 )
226
- return -two54/zero ; /* log(+-0)=-inf */
227
- if (hx<0 ) return (x-x)/zero; /* log(-#) = NaN */
224
+ return -std::numeric_limits< double >:: infinity () ; /* log(+-0)=-inf */
225
+ if (hx<0 ) return std::numeric_limits< double >:: quiet_NaN (); /* log(-#) = NaN */
228
226
k -= 54 ; x *= two54; /* subnormal number, scale up x */
229
227
hx = high (x); /* high word of x */
230
228
}
@@ -516,14 +514,16 @@ static double __ieee754_pow(double x, double y) {
516
514
if (lx==0 ) {
517
515
if (ix==0x7ff00000 ||ix==0 ||ix==0x3ff00000 ){
518
516
z = ax; /* x is +-0,+-inf,+-1*/
519
- if (hy<0 ) z = one/z; /* z = (1/|x|) */
517
+ if (hy<0 ) {
518
+ if (ix == 0 ) {
519
+ z = std::numeric_limits<double >::infinity ();
520
+ } else {
521
+ z = one/z; /* z = (1/|x|) */
522
+ }
523
+ }
520
524
if (hx<0 ) {
521
525
if (((ix-0x3ff00000 )|yisint)==0 ) {
522
- #ifdef CAN_USE_NAN_DEFINE
523
- z = NAN;
524
- #else
525
- z = (z-z)/(z-z); /* (-1)**non-int is NaN */
526
- #endif
526
+ z = std::numeric_limits<double >::quiet_NaN ();
527
527
} else if (yisint==1 )
528
528
z = -1.0 *z; /* (x<0)**odd = -(|x|**odd) */
529
529
}
@@ -534,12 +534,9 @@ static double __ieee754_pow(double x, double y) {
534
534
n = (hx>>31 )+1 ;
535
535
536
536
/* (x<0)**(non-int) is NaN */
537
- if ((n|yisint)==0 )
538
- #ifdef CAN_USE_NAN_DEFINE
539
- return NAN;
540
- #else
541
- return (x-x)/(x-x);
542
- #endif
537
+ if ((n|yisint)==0 ) {
538
+ return std::numeric_limits<double >::quiet_NaN ();
539
+ }
543
540
544
541
s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
545
542
if ((n|(yisint-1 ))==0 ) s = -one;/* (-ve)**(odd int) */
1 commit comments
openjdk-notifier[bot] commentedon Mar 26, 2025
Review
Issues