msvcrt: Set the correct error number in pow(f).

Old versions of MSVC set EDOM on pow(-1, INFINITY) and
pow(-1, -INFINITY) but new versions do not.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alex Henrie 2017-09-14 09:16:57 -06:00 committed by Alexandre Julliard
parent c022c46613
commit 3864851feb
2 changed files with 31 additions and 4 deletions

View File

@ -318,9 +318,11 @@ float CDECL MSVCRT_log10f( float x )
*/
float CDECL MSVCRT_powf( float x, float y )
{
/* FIXME: If x < 0 and y is not integral, set EDOM */
float z = powf(x,y);
if (!finitef(z)) math_error(_DOMAIN, "powf", x, 0, z);
if (x < 0 && y != floorf(y)) math_error(_DOMAIN, "powf", x, y, z);
else if (!x && finitef(y) && y < 0) math_error(_SING, "powf", x, y, z);
else if (finitef(x) && finitef(y) && !finitef(z)) math_error(_OVERFLOW, "powf", x, y, z);
else if (x && finitef(x) && finitef(y) && !z) math_error(_UNDERFLOW, "powf", x, y, z);
return z;
}
@ -530,9 +532,11 @@ double CDECL MSVCRT_log10( double x )
*/
double CDECL MSVCRT_pow( double x, double y )
{
/* FIXME: If x < 0 and y is not integral, set EDOM */
double z = pow(x,y);
if (!isfinite(z)) math_error(_DOMAIN, "pow", x, y, z);
if (x < 0 && y != floor(y)) math_error(_DOMAIN, "pow", x, y, z);
else if (!x && isfinite(y) && y < 0) math_error(_SING, "pow", x, y, z);
else if (isfinite(x) && isfinite(y) && !isfinite(z)) math_error(_OVERFLOW, "pow", x, y, z);
else if (x && isfinite(x) && isfinite(y) && !z) math_error(_UNDERFLOW, "pow", x, y, z);
return z;
}

View File

@ -647,6 +647,29 @@ static void test_math_errors(void)
{"atan2", INFINITY, 0, -1, -1},
{"atan2", 0, -INFINITY, -1, -1},
{"atan2", 0, INFINITY, -1, -1},
{"pow", -INFINITY, -2, -1, -1},
{"pow", -INFINITY, -1, -1, -1},
{"pow", -INFINITY, 0, -1, -1},
{"pow", -INFINITY, 1, -1, -1},
{"pow", -INFINITY, 2, -1, -1},
{"pow", -1e100, -10, -1, _UNDERFLOW},
{"pow", -1e100, 10, ERANGE, _OVERFLOW},
{"pow", -1, 1.5, EDOM, _DOMAIN},
{"pow", 0, -2, ERANGE, _SING},
{"pow", 0, -1, ERANGE, _SING},
{"pow", 0.5, -INFINITY, -1, -1},
{"pow", 0.5, INFINITY, -1, -1},
{"pow", 2, -INFINITY, -1, -1},
{"pow", 2, -1e100, -1, _UNDERFLOW},
{"pow", 2, 1e100, ERANGE, _OVERFLOW},
{"pow", 2, INFINITY, -1, -1},
{"pow", 1e100, -10, -1, _UNDERFLOW},
{"pow", 1e100, 10, ERANGE, _OVERFLOW},
{"pow", INFINITY, -2, -1, -1},
{"pow", INFINITY, -1, -1, -1},
{"pow", INFINITY, 0, -1, -1},
{"pow", INFINITY, 1, -1, -1},
{"pow", INFINITY, 2, -1, -1},
};
const struct {
char func[16];