1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Avoid wrong results for power() with NaN input on more platforms.

Buildfarm results show that the modern POSIX rule that 1 ^ NaN = 1 is not
honored on *BSD until relatively recently, and really old platforms don't
believe that NaN ^ 0 = 1 either.  (This is unsurprising, perhaps, since
SUSv2 doesn't require either behavior.)  In hopes of getting to platform
independent behavior, let's deal with all the NaN-input cases explicitly
in dpow().

Note that numeric_power() doesn't know either of these special cases.
But since that behavior is platform-independent, I think it should be
addressed separately, and probably not back-patched.

Discussion: https://postgr.es/m/75DB81BEEA95B445AE6D576A0A5C9E936A73E741@BPXM05GP.gisp.nec.co.jp
This commit is contained in:
Tom Lane
2018-04-29 18:15:16 -04:00
parent 68e7e973d2
commit 6bdf1303b3
6 changed files with 46 additions and 3 deletions

View File

@ -358,6 +358,12 @@ SELECT power(float8 'NaN', float8 'NaN');
NaN
(1 row)
SELECT power(float8 '-1', float8 'NaN');
power
-------
NaN
(1 row)
SELECT power(float8 '1', float8 'NaN');
power
-------

View File

@ -362,6 +362,12 @@ SELECT power(float8 'NaN', float8 'NaN');
NaN
(1 row)
SELECT power(float8 '-1', float8 'NaN');
power
-------
NaN
(1 row)
SELECT power(float8 '1', float8 'NaN');
power
-------

View File

@ -362,6 +362,12 @@ SELECT power(float8 'NaN', float8 'NaN');
NaN
(1 row)
SELECT power(float8 '-1', float8 'NaN');
power
-------
NaN
(1 row)
SELECT power(float8 '1', float8 'NaN');
power
-------

View File

@ -358,6 +358,12 @@ SELECT power(float8 'NaN', float8 'NaN');
NaN
(1 row)
SELECT power(float8 '-1', float8 'NaN');
power
-------
NaN
(1 row)
SELECT power(float8 '1', float8 'NaN');
power
-------

View File

@ -111,6 +111,7 @@ SELECT power(float8 '144', float8 '0.5');
SELECT power(float8 'NaN', float8 '0.5');
SELECT power(float8 '144', float8 'NaN');
SELECT power(float8 'NaN', float8 'NaN');
SELECT power(float8 '-1', float8 'NaN');
SELECT power(float8 '1', float8 'NaN');
SELECT power(float8 'NaN', float8 '0');