From f6dd30f3a83c9b97557ee3de946777f0f6832d75 Mon Sep 17 00:00:00 2001 From: Jehan Date: Tue, 14 Apr 2020 00:10:09 +0200 Subject: [PATCH] plug-ins: fix more abs(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 #include #include @@ -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; }