diff options
Diffstat (limited to 'src/backend/utils/adt/float.c')
-rw-r--r-- | src/backend/utils/adt/float.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index f74367d64c4..6ad06788fc4 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -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"))); |