Use fabsf() instead of Abs() or fabs() where appropriate
authorPeter Eisentraut <[email protected]>
Sat, 8 Oct 2022 11:41:18 +0000 (13:41 +0200)
committerPeter Eisentraut <[email protected]>
Sat, 8 Oct 2022 11:43:26 +0000 (13:43 +0200)
This function is new in C99.

Reviewed-by: Zhang Mingli <[email protected]>
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/4beb42b5-216b-bce8-d452-d924d5794c63%40enterprisedb.com

contrib/btree_gist/btree_float4.c
contrib/intarray/_int_gist.c
contrib/seg/seg.c
src/backend/utils/adt/float.c

index 3cbd9a06dccfd3ffc2f4214e05617e3ded0341d6..84ca5eee5012cf49466beb4a170578a4dc15ffcb 100644 (file)
@@ -102,7 +102,7 @@ float4_dist(PG_FUNCTION_ARGS)
    if (unlikely(isinf(r)) && !isinf(a) && !isinf(b))
        float_overflow_error();
 
-   PG_RETURN_FLOAT4(Abs(r));
+   PG_RETURN_FLOAT4(fabsf(r));
 }
 
 
index f67699bfccc5a3173678470893edf0c8059bad77..331fa25fcf724313d7d37767cc869002fe57071e 100644 (file)
@@ -540,7 +540,7 @@ g_int_picksplit(PG_FUNCTION_ARGS)
        union_d = inner_int_union(datum_r, datum_alpha);
        rt__int_size(union_d, &size_beta);
        pfree(union_d);
-       costvector[i - 1].cost = fabs((size_alpha - size_l) - (size_beta - size_r));
+       costvector[i - 1].cost = fabsf((size_alpha - size_l) - (size_beta - size_r));
    }
    qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
 
index 9b58675266abbe12decee42afbf67c6563265d8a..e964560053d1b1669951bc61744fac19f38dbe07 100644 (file)
@@ -10,6 +10,7 @@
 #include "postgres.h"
 
 #include <float.h>
+#include <math.h>
 
 #include "access/gist.h"
 #include "access/stratnum.h"
@@ -706,7 +707,7 @@ rt_seg_size(SEG *a, float *size)
    if (a == (SEG *) NULL || a->upper <= a->lower)
        *size = 0.0;
    else
-       *size = (float) Abs(a->upper - a->lower);
+       *size = fabsf(a->upper - a->lower);
 }
 
 Datum
@@ -714,7 +715,7 @@ seg_size(PG_FUNCTION_ARGS)
 {
    SEG        *seg = PG_GETARG_SEG_P(0);
 
-   PG_RETURN_FLOAT4((float) Abs(seg->upper - seg->lower));
+   PG_RETURN_FLOAT4(fabsf(seg->upper - seg->lower));
 }
 
 
index fc8f39a7a9857f3e121d7555cec4b93d21b1efee..da97538ebe304507aaba3c31387d673b661d2619 100644 (file)
@@ -593,7 +593,7 @@ float4abs(PG_FUNCTION_ARGS)
 {
    float4      arg1 = PG_GETARG_FLOAT4(0);
 
-   PG_RETURN_FLOAT4((float4) fabs(arg1));
+   PG_RETURN_FLOAT4(fabsf(arg1));
 }
 
 /*