To preserve the accuracy of the operation, the C standard request that the
mathematical operation is performed using double precision, but in many
case this is not necessary so this patch fixes a few constants to avoid
that conversion.

Signed-off-by: Christophe CURIS <[email protected]>
---
 WINGs/wcolorwell.c         |  2 +-
 WINGs/wscroller.c          | 16 ++++++++--------
 WINGs/wscrollview.c        |  4 ++--
 WPrefs.app/MouseSettings.c |  2 +-
 src/misc.c                 | 12 ++++++------
 wrlib/alpha_combine.c      |  2 +-
 wrlib/context.c            |  2 +-
 wrlib/rotate.c             | 22 +++++++++++-----------
 8 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/WINGs/wcolorwell.c b/WINGs/wcolorwell.c
index a5d1a1d..c67c7d0 100644
--- a/WINGs/wcolorwell.c
+++ b/WINGs/wcolorwell.c
@@ -211,7 +211,7 @@ static void willResizeColorWell(W_ViewDelegate * self, 
WMView * view, unsigned i
                if (*height < MIN_HEIGHT)
                        *height = MIN_HEIGHT;
 
-               bw = (int)((float)WMIN(*width, *height) * 0.24);
+               bw = (int)((float)WMIN(*width, *height) * 0.24F);
 
                W_ResizeView(cPtr->colorView, *width - 2 * bw, *height - 2 * 
bw);
 
diff --git a/WINGs/wscroller.c b/WINGs/wscroller.c
index f1daa3a..4a8f027 100644
--- a/WINGs/wscroller.c
+++ b/WINGs/wscroller.c
@@ -168,10 +168,10 @@ void WMSetScrollerParameters(WMScroller * sPtr, float 
floatValue, float knobProp
 
        assert(!isnan(floatValue));
 
-       if (floatValue < 0.0)
-               sPtr->floatValue = 0.0;
-       else if (floatValue > 1.0)
-               sPtr->floatValue = 1.0;
+       if (floatValue < 0.0F)
+               sPtr->floatValue = 0.0F;
+       else if (floatValue > 1.0F)
+               sPtr->floatValue = 1.0F;
        else
                sPtr->floatValue = floatValue;
 
@@ -180,9 +180,9 @@ void WMSetScrollerParameters(WMScroller * sPtr, float 
floatValue, float knobProp
                sPtr->knobProportion = min_knob_proportion;
                sPtr->flags.documentFullyVisible = 0;
 
-       } else if (knobProportion >= 1.0) {
+       } else if (knobProportion >= 1.0F) {
 
-               sPtr->knobProportion = 1.0;
+               sPtr->knobProportion = 1.0F;
                sPtr->flags.documentFullyVisible = 1;
 
        } else {
@@ -344,7 +344,7 @@ static int knobLength(Scroller * sPtr)
                length -= 2 * (BUTTON_SIZE + 1);
        }
 
-       tmp = (int)((float)length * sPtr->knobProportion + 0.5);
+       tmp = (int)((float)length * sPtr->knobProportion + 0.5F);
        /* keep minimum size */
        if (tmp < BUTTON_SIZE)
                tmp = BUTTON_SIZE;
@@ -418,7 +418,7 @@ static void paintScroller(Scroller * sPtr)
                                               length - (int)(knobP + knobL), 
view->size.height - 4);
                } else {
                        /* before */
-                       if (knobP > 0.0)
+                       if (knobP > 0.0F)
                                XFillRectangle(scr->display, d, scr->stippleGC,
                                               2, ofs, view->size.width - 4, 
(int)knobP);
 
diff --git a/WINGs/wscrollview.c b/WINGs/wscrollview.c
index a21864e..a1b030e 100644
--- a/WINGs/wscrollview.c
+++ b/WINGs/wscrollview.c
@@ -506,7 +506,7 @@ static void updateScrollerProportion(ScrollView * sPtr)
 
                prop = (float)sPtr->viewport->size.width / 
(float)sPtr->contentView->size.width;
 
-               if (oldP < 1.0)
+               if (oldP < 1.0F)
                        value = (prop * oldV) / oldP;
                else
                        value = 0;
@@ -518,7 +518,7 @@ static void updateScrollerProportion(ScrollView * sPtr)
 
                prop = (float)sPtr->viewport->size.height / 
(float)sPtr->contentView->size.height;
 
-               if (oldP < 1.0)
+               if (oldP < 1.0F)
                        value = (prop * oldV) / oldP;
                else
                        value = 0;
diff --git a/WPrefs.app/MouseSettings.c b/WPrefs.app/MouseSettings.c
index 6df9300..7859f14 100644
--- a/WPrefs.app/MouseSettings.c
+++ b/WPrefs.app/MouseSettings.c
@@ -298,7 +298,7 @@ static void showData(_Panel * panel)
        sprintf(buffer, "%i", a);
        WMSetTextFieldText(panel->threT, buffer);
 
-       WMSetSliderValue(panel->speedS, (accel - 0.25) / 0.25);
+       WMSetSliderValue(panel->speedS, (accel - 0.25F) / 0.25F);
 
        panel->acceleration = accel;
        sprintf(buffer, "%.2f", accel);
diff --git a/src/misc.c b/src/misc.c
index 99341d3..02aa401 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -201,14 +201,14 @@ void slide_windows(Window wins[], int n, int from_x, int 
from_y, int to_x, int t
                        px = slide_steps;
                else if (px > -slide_steps && px < 0)
                        px = -slide_steps;
-               py = (is_dx_nul ? 0.0 : px * dy / dx);
+               py = (is_dx_nul ? 0.0F : px * dy / dx);
        } else {
                py = dy / slide_slowdown;
                if (py < slide_steps && py > 0)
                        py = slide_steps;
                else if (py > -slide_steps && py < 0)
                        py = -slide_steps;
-               px = (is_dy_nul ? 0.0 : py * dx / dy);
+               px = (is_dy_nul ? 0.0F : py * dx / dy);
        }
 
        while (((int)x) != to_x ||
@@ -221,19 +221,19 @@ void slide_windows(Window wins[], int n, int from_x, int 
from_y, int to_x, int t
                        y = (float)to_y;
 
                if (dx_is_bigger) {
-                       px = px * (1.0 - 1 / (float)slide_slowdown);
+                       px = px * (1.0F - 1 / (float)slide_slowdown);
                        if (px < slide_steps && px > 0)
                                px = slide_steps;
                        else if (px > -slide_steps && px < 0)
                                px = -slide_steps;
-                       py = (is_dx_nul ? 0.0 : px * dy / dx);
+                       py = (is_dx_nul ? 0.0F : px * dy / dx);
                } else {
-                       py = py * (1.0 - 1 / (float)slide_slowdown);
+                       py = py * (1.0F - 1 / (float)slide_slowdown);
                        if (py < slide_steps && py > 0)
                                py = slide_steps;
                        else if (py > -slide_steps && py < 0)
                                py = -slide_steps;
-                       px = (is_dy_nul ? 0.0 : py * dx / dy);
+                       px = (is_dy_nul ? 0.0F : py * dx / dy);
                }
 
                for (i = 0; i < n; i++) {
diff --git a/wrlib/alpha_combine.c b/wrlib/alpha_combine.c
index b410186..7f08a50 100644
--- a/wrlib/alpha_combine.c
+++ b/wrlib/alpha_combine.c
@@ -47,7 +47,7 @@ void RCombineAlpha(unsigned char *d, unsigned char *s, int 
s_has_alpha,
                                cratio = 0;
                        } else {
                                ratio = (float)sa / alpha;
-                               cratio = 1.0 - ratio;
+                               cratio = 1.0F - ratio;
                        }
 
                        *d = (int)*d * cratio + (int)*s * ratio;
diff --git a/wrlib/context.c b/wrlib/context.c
index 4c40c88..d74bf53 100644
--- a/wrlib/context.c
+++ b/wrlib/context.c
@@ -438,7 +438,7 @@ static void gatherconfig(RContext * context, int screen_n)
        ptr = mygetenv("WRASTER_GAMMA", screen_n);
        if (ptr) {
                float g1, g2, g3;
-               if (sscanf(ptr, "%f/%f/%f", &g1, &g2, &g3) != 3 || g1 <= 0.0 || 
g2 <= 0.0 || g3 <= 0.0) {
+               if (sscanf(ptr, "%f/%f/%f", &g1, &g2, &g3) != 3 || g1 <= 0.0F 
|| g2 <= 0.0F || g3 <= 0.0F) {
                        printf("wrlib: invalid value(s) for gamma correction 
\"%s\"\n", ptr);
                } else {
                        context->attribs->flags |= RC_GammaCorrection;
diff --git a/wrlib/rotate.c b/wrlib/rotate.c
index 482b317..9ffaa30 100644
--- a/wrlib/rotate.c
+++ b/wrlib/rotate.c
@@ -48,26 +48,26 @@ RImage *RRotateImage(RImage *image, float angle)
         * candidate for an Epsilon when trying to compare angle
         * to known values
         */
-       static const float min_usable_angle = 0.00699;
+       static const float min_usable_angle = 0.00699F;
 
        angle = fmod(angle, 360.0);
-       if (angle < 0.0)
-               angle += 360.0;
+       if (angle < 0.0F)
+               angle += 360.0F;
 
        if (angle < min_usable_angle) {
                /* Rotate by 0 degree */
                return RCloneImage(image);
 
-       } else if ((angle > 90.0 - min_usable_angle) &&
-                                 (angle < 90.0 + min_usable_angle)) {
+       } else if ((angle > 90.0F - min_usable_angle) &&
+                                 (angle < 90.0F + min_usable_angle)) {
                return rotate_image_90(image);
 
-       } else if ((angle > 180.0 - min_usable_angle) &&
-                                 (angle < 180.0 + min_usable_angle)) {
+       } else if ((angle > 180.0F - min_usable_angle) &&
+                                 (angle < 180.0F + min_usable_angle)) {
                return wraster_rotate_image_180(image);
 
-       } else if ((angle > 270.0 - min_usable_angle) &&
-                                 (angle < 270.0 + min_usable_angle)) {
+       } else if ((angle > 270.0F - min_usable_angle) &&
+                                 (angle < 270.0F + min_usable_angle)) {
                return rotate_image_270(image);
 
        } else {
@@ -341,8 +341,8 @@ static RImage *rotate_image_any(RImage *source, float angle)
        int dpr, dpru, p;
 
        /* only 180o for now */
-       if (angle > 180.0)
-               angle -= 180.0;
+       if (angle > 180.0F)
+               angle -= 180.0F;
 
        angle = (angle * WM_PI) / 180.0;
 
-- 
2.1.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to