[Wasm] fdlibm NFC: Replace division by zero with inf and NaN constants

Fixes warnings.
This commit is contained in:
Svyatoslav Kuzmich
2023-01-20 14:29:51 +01:00
parent 181e1023ed
commit 3acf371f8a
4 changed files with 8 additions and 8 deletions
@@ -100,8 +100,8 @@ internal fun __ieee754_log(_x: Double): Double {
k = 0
if (hx < 0x00100000) { /* x < 2**-1022 */
if (((hx and 0x7fffffff) or lx.toInt()) == 0)
return -two54 / zero /* log(+-0)=-inf */
if (hx < 0) return (x - x) / zero /* log(-#) = NaN */
return Double.NEGATIVE_INFINITY /* log(+-0)=-inf */
if (hx < 0) return Double.NaN /* log(-#) = NaN */
k -= 54; x *= two54 /* subnormal number, scale up x */
hx = __HI(x) /* high word of x */
}
@@ -67,8 +67,8 @@ internal fun __ieee754_log10(_x: Double): Double {
k = 0
if (hx < 0x00100000) { /* x < 2**-1022 */
if (((hx and 0x7fffffff) or lx.toInt()) == 0)
return -two54 / zero /* log(+-0)=-inf */
if (hx < 0) return (x - x) / zero /* log(-#) = NaN */
return Double.NEGATIVE_INFINITY /* log(+-0)=-inf */
if (hx < 0) return Double.NaN /* log(-#) = NaN */
k -= 54; x *= two54 /* subnormal number, scale up x */
hx = __HI(x) /* high word of x */
}
@@ -56,8 +56,8 @@ internal fun __ieee754_log2(_x: Double): Double {
k = 0
if (hx < 0x00100000) { /* x < 2**-1022 */
if (((hx and 0x7fffffff) or lx.toInt()) == 0)
return -two54 / zero /* log(+-0)=-inf */
if (hx < 0) return (x - x) / zero /* log(-#) = NaN */
return Double.NEGATIVE_INFINITY /* log(+-0)=-inf */
if (hx < 0) return Double.NaN /* log(-#) = NaN */
k -= 54; x *= two54 /* subnormal number, scale up x */
hx = __HI(x) /* high word of x */
}
@@ -110,8 +110,8 @@ internal fun log1p(x: Double): Double {
k = 1
if (hx < 0x3FDA827A) { /* x < 0.41422 */
if (ax >= 0x3ff00000) { /* x <= -1.0 */
if (x == -1.0) return -two54 / zero /* log1p(-1)=+inf */
else return (x - x) / (x - x) /* log1p(x<-1)=NaN */
if (x == -1.0) return Double.NEGATIVE_INFINITY /* log1p(-1)=-inf */
else return Double.NaN /* log1p(x<-1)=NaN */
}
if (ax < 0x3e200000) { /* |x| < 2**-29 */
if (two54 + x > zero /* raise inexact */