Skip to content

Commit f74b94d

Browse files
committed
Finally found a platform which has finite() but nonetheless sets errno
rather than returning a NaN for bogus input to pow(). Namely, HPUX 10.20. I think this is sufficient evidence for what I thought all along, which is that the float.c code *must* look at errno whether finite() exists or not.
1 parent 76b110c commit f74b94d

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/backend/utils/adt/float.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.50 1999/10/02 17:45:31 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.51 1999/12/20 02:15:35 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1157,16 +1157,17 @@ dpow(float64 arg1, float64 arg2)
11571157

11581158
tmp1 = *arg1;
11591159
tmp2 = *arg2;
1160-
#ifndef HAVE_FINITE
1160+
1161+
/* We must check both for errno getting set and for a NaN result,
1162+
* in order to deal with the vagaries of different platforms...
1163+
*/
11611164
errno = 0;
1162-
#endif
11631165
*result = (float64data) pow(tmp1, tmp2);
1164-
#ifndef HAVE_FINITE
1165-
if (errno != 0) /* on some machines both EDOM & ERANGE can
1166-
* occur */
1167-
#else
1168-
if (!finite(*result))
1166+
if (errno != 0
1167+
#ifdef HAVE_FINITE
1168+
|| !finite(*result)
11691169
#endif
1170+
)
11701171
elog(ERROR, "pow() result is out of range");
11711172

11721173
CheckFloat8Val(*result);
@@ -1189,16 +1190,18 @@ dexp(float64 arg1)
11891190
result = (float64) palloc(sizeof(float64data));
11901191

11911192
tmp = *arg1;
1192-
#ifndef HAVE_FINITE
1193+
1194+
/* We must check both for errno getting set and for a NaN result,
1195+
* in order to deal with the vagaries of different platforms.
1196+
* Also, a zero result implies unreported underflow.
1197+
*/
11931198
errno = 0;
1194-
#endif
11951199
*result = (float64data) exp(tmp);
1196-
#ifndef HAVE_FINITE
1197-
if (errno == ERANGE)
1198-
#else
1199-
/* infinity implies overflow, zero implies underflow */
1200-
if (!finite(*result) || *result == 0.0)
1200+
if (errno != 0 || *result == 0.0
1201+
#ifdef HAVE_FINITE
1202+
|| !finite(*result)
12011203
#endif
1204+
)
12021205
elog(ERROR, "exp() result is out of range");
12031206

12041207
CheckFloat8Val(*result);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy