Commit 92eacaf5 authored by Tom Lane's avatar Tom Lane

Change exp() behavior to generate error on underflow rather

than silently returning zero on some machines.  Correct float8 regress test
to agree.  Also fix pow() overflow/underflow check to work correctly on
HPUX.
parent 67531c42
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.34 1998/11/17 14:36:44 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.35 1998/11/29 01:57:59 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1131,7 +1131,7 @@ dpow(float64 arg1, float64 arg2) ...@@ -1131,7 +1131,7 @@ dpow(float64 arg1, float64 arg2)
#endif #endif
*result = (float64data) pow(tmp1, tmp2); *result = (float64data) pow(tmp1, tmp2);
#ifndef finite #ifndef finite
if (errno == ERANGE) if (errno != 0) /* on some machines both EDOM & ERANGE can occur */
#else #else
if (!finite(*result)) if (!finite(*result))
#endif #endif
...@@ -1164,7 +1164,8 @@ dexp(float64 arg1) ...@@ -1164,7 +1164,8 @@ dexp(float64 arg1)
#ifndef finite #ifndef finite
if (errno == ERANGE) if (errno == ERANGE)
#else #else
if (!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");
......
...@@ -195,15 +195,7 @@ ERROR: can't take log of zero ...@@ -195,15 +195,7 @@ ERROR: can't take log of zero
QUERY: SELECT '' AS bad, (; (f.f1)) from FLOAT8_TBL f where f.f1 < '0.0' ; QUERY: SELECT '' AS bad, (; (f.f1)) from FLOAT8_TBL f where f.f1 < '0.0' ;
ERROR: can't take log of a negative number ERROR: can't take log of a negative number
QUERY: SELECT '' AS bad, : (f.f1) from FLOAT8_TBL f; QUERY: SELECT '' AS bad, : (f.f1) from FLOAT8_TBL f;
bad| ?column? ERROR: exp() result is out of range
---+--------------------
| 1
|7.39912306090513e-16
| 0
| 0
| 1
(5 rows)
QUERY: SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f; QUERY: SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
ERROR: float8div: divide by zero error ERROR: float8div: divide by zero error
QUERY: SELECT '' AS five, FLOAT8_TBL.*; QUERY: SELECT '' AS five, FLOAT8_TBL.*;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment