Commit 21cbe74b authored by Alexandre Julliard's avatar Alexandre Julliard

msvcrt: Use the log2()/log2f() implementation from the bundled musl library.

parent 714874ba
......@@ -65,12 +65,18 @@ double __cdecl log2(double x)
}
if (predict_false(top - 0x0010 >= 0x7ff0 - 0x0010)) {
/* x < 0x1p-1022 or inf or nan. */
if (ix * 2 == 0)
if (ix * 2 == 0) {
errno = ERANGE;
return __math_divzero(1);
}
if (ix == asuint64(INFINITY)) /* log(inf) == inf. */
return x;
if ((top & 0x8000) || (top & 0x7ff0) == 0x7ff0)
if ((top & 0x7ff0) == 0x7ff0 && (ix & 0xfffffffffffffULL))
return x;
if (top & 0x8000) {
errno = EDOM;
return __math_invalid(x);
}
/* x is subnormal, normalize it. */
ix = asuint64(x * 0x1p52);
ix -= 52ULL << 52;
......
......@@ -35,12 +35,18 @@ float __cdecl log2f(float x)
return 0;
if (predict_false(ix - 0x00800000 >= 0x7f800000 - 0x00800000)) {
/* x < 0x1p-126 or inf or nan. */
if (ix * 2 == 0)
if (ix * 2 == 0) {
errno = ERANGE;
return __math_divzerof(1);
}
if (ix == 0x7f800000) /* log2(inf) == inf. */
return x;
if ((ix & 0x80000000) || ix * 2 >= 0xff000000)
if (ix * 2 > 0xff000000)
return x;
if (ix & 0x80000000) {
errno = EDOM;
return __math_invalidf(x);
}
/* x is subnormal, normalize it. */
ix = asuint(x * 0x1p23f);
ix -= 23 << 23;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment