Skip to content

Commit e4c61be

Browse files
committed
Use fabsf() instead of Abs() or fabs() where appropriate
This function is new in C99. Reviewed-by: Zhang Mingli <zmlpostgres@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/4beb42b5-216b-bce8-d452-d924d5794c63%40enterprisedb.com
1 parent 2473cb9 commit e4c61be

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

contrib/btree_gist/btree_float4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ float4_dist(PG_FUNCTION_ARGS)
102102
if (unlikely(isinf(r)) && !isinf(a) && !isinf(b))
103103
float_overflow_error();
104104

105-
PG_RETURN_FLOAT4(Abs(r));
105+
PG_RETURN_FLOAT4(fabsf(r));
106106
}
107107

108108

contrib/intarray/_int_gist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ g_int_picksplit(PG_FUNCTION_ARGS)
540540
union_d = inner_int_union(datum_r, datum_alpha);
541541
rt__int_size(union_d, &size_beta);
542542
pfree(union_d);
543-
costvector[i - 1].cost = fabs((size_alpha - size_l) - (size_beta - size_r));
543+
costvector[i - 1].cost = fabsf((size_alpha - size_l) - (size_beta - size_r));
544544
}
545545
qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
546546

contrib/seg/seg.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "postgres.h"
1111

1212
#include <float.h>
13+
#include <math.h>
1314

1415
#include "access/gist.h"
1516
#include "access/stratnum.h"
@@ -706,15 +707,15 @@ rt_seg_size(SEG *a, float *size)
706707
if (a == (SEG *) NULL || a->upper <= a->lower)
707708
*size = 0.0;
708709
else
709-
*size = (float) Abs(a->upper - a->lower);
710+
*size = fabsf(a->upper - a->lower);
710711
}
711712

712713
Datum
713714
seg_size(PG_FUNCTION_ARGS)
714715
{
715716
SEG *seg = PG_GETARG_SEG_P(0);
716717

717-
PG_RETURN_FLOAT4((float) Abs(seg->upper - seg->lower));
718+
PG_RETURN_FLOAT4(fabsf(seg->upper - seg->lower));
718719
}
719720

720721

src/backend/utils/adt/float.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ float4abs(PG_FUNCTION_ARGS)
593593
{
594594
float4 arg1 = PG_GETARG_FLOAT4(0);
595595

596-
PG_RETURN_FLOAT4((float4) fabs(arg1));
596+
PG_RETURN_FLOAT4(fabsf(arg1));
597597
}
598598

599599
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy