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.
This commit is contained in:
Tom Lane 1999-12-20 02:15:35 +00:00
parent 76b110c82a
commit f74b94db09
1 changed files with 18 additions and 15 deletions

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.50 1999/10/02 17:45:31 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.51 1999/12/20 02:15:35 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1157,16 +1157,17 @@ dpow(float64 arg1, float64 arg2)
tmp1 = *arg1; tmp1 = *arg1;
tmp2 = *arg2; tmp2 = *arg2;
#ifndef HAVE_FINITE
/* We must check both for errno getting set and for a NaN result,
* in order to deal with the vagaries of different platforms...
*/
errno = 0; errno = 0;
#endif
*result = (float64data) pow(tmp1, tmp2); *result = (float64data) pow(tmp1, tmp2);
#ifndef HAVE_FINITE if (errno != 0
if (errno != 0) /* on some machines both EDOM & ERANGE can #ifdef HAVE_FINITE
* occur */ || !finite(*result)
#else
if (!finite(*result))
#endif #endif
)
elog(ERROR, "pow() result is out of range"); elog(ERROR, "pow() result is out of range");
CheckFloat8Val(*result); CheckFloat8Val(*result);
@ -1189,16 +1190,18 @@ dexp(float64 arg1)
result = (float64) palloc(sizeof(float64data)); result = (float64) palloc(sizeof(float64data));
tmp = *arg1; tmp = *arg1;
#ifndef HAVE_FINITE
/* We must check both for errno getting set and for a NaN result,
* in order to deal with the vagaries of different platforms.
* Also, a zero result implies unreported underflow.
*/
errno = 0; errno = 0;
#endif
*result = (float64data) exp(tmp); *result = (float64data) exp(tmp);
#ifndef HAVE_FINITE if (errno != 0 || *result == 0.0
if (errno == ERANGE) #ifdef HAVE_FINITE
#else || !finite(*result)
/* infinity implies overflow, zero implies underflow */
if (!finite(*result) || *result == 0.0)
#endif #endif
)
elog(ERROR, "exp() result is out of range"); elog(ERROR, "exp() result is out of range");
CheckFloat8Val(*result); CheckFloat8Val(*result);