diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 1999-12-20 02:15:35 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 1999-12-20 02:15:35 +0000 |
commit | f74b94db0922b1ef8ac247d573a935efca2ca97b (patch) | |
tree | d9bc8674b8e0be1c7255afad03d63435fcaf7ff8 /src/backend/utils/adt/float.c | |
parent | 76b110c82a23f996668d30043bf790dd0768c34b (diff) | |
download | postgresql-f74b94db0922b1ef8ac247d573a935efca2ca97b.tar.gz postgresql-f74b94db0922b1ef8ac247d573a935efca2ca97b.zip |
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.
Diffstat (limited to 'src/backend/utils/adt/float.c')
-rw-r--r-- | src/backend/utils/adt/float.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 6f65f615cc6..6145ad04614 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -7,7 +7,7 @@ * * * 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; 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; -#endif *result = (float64data) pow(tmp1, tmp2); -#ifndef HAVE_FINITE - if (errno != 0) /* on some machines both EDOM & ERANGE can - * occur */ -#else - if (!finite(*result)) + if (errno != 0 +#ifdef HAVE_FINITE + || !finite(*result) #endif + ) elog(ERROR, "pow() result is out of range"); CheckFloat8Val(*result); @@ -1189,16 +1190,18 @@ dexp(float64 arg1) result = (float64) palloc(sizeof(float64data)); 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; -#endif *result = (float64data) exp(tmp); -#ifndef HAVE_FINITE - if (errno == ERANGE) -#else - /* infinity implies overflow, zero implies underflow */ - if (!finite(*result) || *result == 0.0) + if (errno != 0 || *result == 0.0 +#ifdef HAVE_FINITE + || !finite(*result) #endif + ) elog(ERROR, "exp() result is out of range"); CheckFloat8Val(*result); |