[gimp/gimp-2-10] plug-ins: fix more abs().
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] plug-ins: fix more abs().
- Date: Sun, 19 Apr 2020 10:59:00 +0000 (UTC)
commit 2229b735bb43e8ff29a04f8d257e6b8c4a98f6e8
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]
(cherry picked from commit f6dd30f3a83c9b97557ee3de946777f0f6832d75)
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]