mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
Remove the special cases to prevent minus-zero results in float4 and float8
unary minus operators. We weren't attempting to prevent minus zero anywhere else; in view of our gradual trend to make the float datatypes more IEEE standard compliant, we should allow minus zero here rather than disallow it elsewhere. We don't, however, expect that all platforms will produce minus zero, so we need to adjust the one affected regression test to allow both results. Per discussion of bug #4660. (In passing, clean up a couple other minor infelicities in float.c.)
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.159 2009/01/01 17:23:49 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.160 2009/02/18 19:23:26 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -576,9 +576,7 @@ float4um(PG_FUNCTION_ARGS)
|
||||
float4 arg1 = PG_GETARG_FLOAT4(0);
|
||||
float4 result;
|
||||
|
||||
result = ((arg1 != 0) ? -(arg1) : arg1);
|
||||
|
||||
CHECKFLOATVAL(result, isinf(arg1), true);
|
||||
result = -arg1;
|
||||
PG_RETURN_FLOAT4(result);
|
||||
}
|
||||
|
||||
@ -645,9 +643,7 @@ float8um(PG_FUNCTION_ARGS)
|
||||
float8 arg1 = PG_GETARG_FLOAT8(0);
|
||||
float8 result;
|
||||
|
||||
result = ((arg1 != 0) ? -(arg1) : arg1);
|
||||
|
||||
CHECKFLOATVAL(result, isinf(arg1), true);
|
||||
result = -arg1;
|
||||
PG_RETURN_FLOAT8(result);
|
||||
}
|
||||
|
||||
@ -703,16 +699,16 @@ float8smaller(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
float4pl(PG_FUNCTION_ARGS)
|
||||
{
|
||||
float8 arg1 = PG_GETARG_FLOAT4(0);
|
||||
float8 arg2 = PG_GETARG_FLOAT4(1);
|
||||
float4 arg1 = PG_GETARG_FLOAT4(0);
|
||||
float4 arg2 = PG_GETARG_FLOAT4(1);
|
||||
float4 result;
|
||||
|
||||
result = arg1 + arg2;
|
||||
|
||||
/*
|
||||
* There isn't any way to check for underflow of addition/subtraction
|
||||
* because numbers near the underflow value have been already been to the
|
||||
* point where we can't detect the that the two values were originally
|
||||
* because numbers near the underflow value have already been rounded to
|
||||
* the point where we can't detect that the two values were originally
|
||||
* different, e.g. on x86, '1e-45'::float4 == '2e-45'::float4 ==
|
||||
* 1.4013e-45.
|
||||
*/
|
||||
@ -757,7 +753,6 @@ float4div(PG_FUNCTION_ARGS)
|
||||
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
||||
errmsg("division by zero")));
|
||||
|
||||
/* Do division in float8, then check for overflow */
|
||||
result = arg1 / arg2;
|
||||
|
||||
CHECKFLOATVAL(result, isinf(arg1) || isinf(arg2), arg1 == 0);
|
||||
@ -2693,7 +2688,7 @@ width_bucket_float8(PG_FUNCTION_ARGS)
|
||||
errmsg("operand, lower bound and upper bound cannot be NaN")));
|
||||
|
||||
/* Note that we allow "operand" to be infinite */
|
||||
if (is_infinite(bound1) || is_infinite(bound2))
|
||||
if (isinf(bound1) || isinf(bound2))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_ARGUMENT_FOR_WIDTH_BUCKET_FUNCTION),
|
||||
errmsg("lower and upper bounds must be finite")));
|
||||
|
Reference in New Issue
Block a user