Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit990fea8

Browse files
committed
Attempt to return proper overflow/underflow messages for platforms that
only return Nan and set errno for pow/exp overflow/underflow.
1 parentada6fd6 commit990fea8

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

‎src/backend/utils/adt/float.c

Lines changed: 23 additions & 6 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.136 2007/01/0304:21:47 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.137 2007/01/0314:35:24 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1440,11 +1440,19 @@ dpow(PG_FUNCTION_ARGS)
14401440

14411441
/*
14421442
* pow() sets errno only on some platforms, depending on whether it
1443-
* follows _IEEE_, _POSIX_, _XOPEN_, or _SVID_,so, for consistency,
1444-
* wedon't consult itandjust do our check below.
1443+
* follows _IEEE_, _POSIX_, _XOPEN_, or _SVID_,and some return Nan,
1444+
*sowecheckandset result properly.
14451445
*/
1446+
errno=0;
14461447
result=pow(arg1,arg2);
1447-
1448+
if (errno==ERANGE&&isnan(result))
1449+
{
1450+
if ((fabs(arg1)>1&&arg2 >=0)|| (fabs(arg1)<1&&arg2<0))
1451+
result= (arg1 >=0) ?get_float8_infinity() :-get_float8_infinity();
1452+
else
1453+
result=0;
1454+
}
1455+
14481456
CHECKFLOATVAL(result,isinf(arg1)||isinf(arg2),arg1==0);
14491457
PG_RETURN_FLOAT8(result);
14501458
}
@@ -1461,10 +1469,19 @@ dexp(PG_FUNCTION_ARGS)
14611469

14621470
/*
14631471
* exp() sets errno only on some platforms, depending on whether it
1464-
* follows _IEEE_, _POSIX_, _XOPEN_, or _SVID_,so, for consistency,
1465-
* wedon't consult itandjust do our check below.
1472+
* follows _IEEE_, _POSIX_, _XOPEN_, or _SVID_,and some return Nan,
1473+
*sowecheckandset result properly.
14661474
*/
1475+
errno=0;
14671476
result=exp(arg1);
1477+
if (errno==ERANGE&&isnan(result))
1478+
{
1479+
if (arg1 >=0)
1480+
result=get_float8_infinity();
1481+
else
1482+
result=0;
1483+
}
1484+
14681485

14691486
CHECKFLOATVAL(result,isinf(arg1), false);
14701487
PG_RETURN_FLOAT8(result);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp