Commit 400f1693 authored by Tom Lane's avatar Tom Lane

In dpow(), remove redundant check for whether y is an integer.

I failed to notice that we don't really need to check for y being an
integer in the code path where x = -inf; we already did.

Also make some further cosmetic rearrangements in that spot in hopes
of dodging the seeming compiler bug that buildfarm member fossa is
hitting.  And be consistent about declaring variables as "float8"
not "double", since the pre-existing variables in this function are
like that.

Discussion: https://postgr.es/m/E1jkyFX-0005RR-1Q@gemulon.postgresql.org
parent 4dd804a9
...@@ -1546,7 +1546,7 @@ dpow(PG_FUNCTION_ARGS) ...@@ -1546,7 +1546,7 @@ dpow(PG_FUNCTION_ARGS)
*/ */
if (isinf(arg2)) if (isinf(arg2))
{ {
double absx = fabs(arg1); float8 absx = fabs(arg1);
if (absx == 1.0) if (absx == 1.0)
result = 1.0; result = 1.0;
...@@ -1578,16 +1578,15 @@ dpow(PG_FUNCTION_ARGS) ...@@ -1578,16 +1578,15 @@ dpow(PG_FUNCTION_ARGS)
} }
else /* x = -Inf */ else /* x = -Inf */
{ {
bool yisoddinteger = false; /*
* Per POSIX, the sign of the result depends on whether y is an
if (arg2 == floor(arg2)) * odd integer. Since x < 0, we already know from the previous
{ * domain check that y is an integer. It is odd if y/2 is not
/* y is integral; it's odd if y/2 is not integral */ * also an integer.
double halfy = arg2 / 2; /* should be computed exactly */ */
float8 halfy = arg2 / 2; /* should be computed exactly */
bool yisoddinteger = (floor(halfy) != halfy);
if (halfy != floor(halfy))
yisoddinteger = true;
}
if (arg2 > 0.0) if (arg2 > 0.0)
result = yisoddinteger ? arg1 : -arg1; result = yisoddinteger ? arg1 : -arg1;
else else
...@@ -1622,7 +1621,7 @@ dpow(PG_FUNCTION_ARGS) ...@@ -1622,7 +1621,7 @@ dpow(PG_FUNCTION_ARGS)
result = 0.0; /* we already verified y is positive */ result = 0.0; /* we already verified y is positive */
else else
{ {
double absx = fabs(arg1); float8 absx = fabs(arg1);
if (absx == 1.0) if (absx == 1.0)
result = 1.0; result = 1.0;
......
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