[gimp] plug-ins: fix more abs().
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: fix more abs().
- Date: Mon, 13 Apr 2020 22:13:32 +0000 (UTC)
commit f6dd30f3a83c9b97557ee3de946777f0f6832d75
Author: Jehan <jehan girinstud io>
Date: Tue Apr 14 00:10:09 2020 +0200
plug-ins: fix more abs().
I am comparing absolute value of 2 double computation results. Might as
well just use fabs() instead of truncating both values to int.
Fixes the following:
> warning: using integer absolute value function ‘abs’ when argument is
> of floating point type ‘double’ [-Wabsolute-value]
plug-ins/gfig/gfig-grid.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/gfig/gfig-grid.c b/plug-ins/gfig/gfig-grid.c
index 687eb9458c..ac81859e5b 100644
--- a/plug-ins/gfig/gfig-grid.c
+++ b/plug-ins/gfig/gfig-grid.c
@@ -23,6 +23,7 @@
#include "config.h"
+#include <math.h>
#include <stdlib.h>
#include <libgimp/gimp.h>
@@ -309,8 +310,8 @@ find_grid_pos (GdkPoint *p,
m_hi_n_lo = m_lo_n_lo + 1;
/* figure out which is the better candidate */
- if (abs ((m_lo_n_lo * r + (0.5 * r * (n_lo % 2))) - y) <
- abs ((m_hi_n_lo * r + (0.5 * r * (n_lo % 2))) - y))
+ if (fabs ((m_lo_n_lo * r + (0.5 * r * (n_lo % 2))) - y) <
+ fabs ((m_hi_n_lo * r + (0.5 * r * (n_lo % 2))) - y))
{
m_n_lo = m_lo_n_lo;
}
@@ -324,8 +325,8 @@ find_grid_pos (GdkPoint *p,
m_hi_n_hi = m_lo_n_hi + 1;
/* figure out which is the better candidate */
- if (abs((m_lo_n_hi * r + (0.5 * r * (n_hi % 2))) - y) <
- abs((m_hi_n_hi * r + (0.5 * r * (n_hi % 2))) - y))
+ if (fabs((m_lo_n_hi * r + (0.5 * r * (n_hi % 2))) - y) <
+ fabs((m_hi_n_hi * r + (0.5 * r * (n_hi % 2))) - y))
{
m_n_hi = m_lo_n_hi;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]