Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f0f4a6d

Browse files
committed
Apply fix so pow() and exp() ERANGE is used only if result is not 0.
1 parent 282f7f2 commit f0f4a6d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/utils/adt/float.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.145 2007/01/06 15:18:02 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.146 2007/01/06 20:21:29 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1459,7 +1459,7 @@ dpow(PG_FUNCTION_ARGS)
14591459
else
14601460
result = 1;
14611461
}
1462-
else if (errno == ERANGE && !isinf(result))
1462+
else if (errno == ERANGE && result != 0 && !isinf(result))
14631463
result = get_float8_infinity();
14641464

14651465
CHECKFLOATVAL(result, isinf(arg1) || isinf(arg2), arg1 == 0);
@@ -1478,7 +1478,7 @@ dexp(PG_FUNCTION_ARGS)
14781478

14791479
errno = 0;
14801480
result = exp(arg1);
1481-
if (errno == ERANGE && !isinf(result))
1481+
if (errno == ERANGE && result != 0 && !isinf(result))
14821482
result = get_float8_infinity();
14831483

14841484
CHECKFLOATVAL(result, isinf(arg1), false);

0 commit comments

Comments
 (0)