summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2024-08-28 17:05:18 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2024-08-28 17:05:18 -0700
commit571d6fe3a04bd5bf598a4a7ad0b1c56c6c3bfe1d (patch)
tree94a0e186bcaad7e73d04245d2c394711810b850f
parent7c426e265997398ee4a0bfa935db0c829875671e (diff)
Use double for all floating point numbers, not a mix of double and float
Gets rid of a lot of inadvertent converting back and forth, along with clearing up 49 -Wdouble-promotion, 12 -Wimplicit-float-conversion, and 6 -Wimplicit-int-float-conversion warnings from clang 13. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/app/xmag/-/merge_requests/5>
-rw-r--r--Scale.c20
-rw-r--r--ScaleP.h6
2 files changed, 13 insertions, 13 deletions
diff --git a/Scale.c b/Scale.c
index 2e9630f..b0aa79f 100644
--- a/Scale.c
+++ b/Scale.c
@@ -572,10 +572,10 @@ Redisplay(Widget w, XEvent *event, _X_UNUSED Region region)
height = event->xexpose.height;
}
- img_x = min(max((Position) floor((float) x / sw->scale.scale_x), 0),
+ img_x = min(max((Position) floor(x / sw->scale.scale_x), 0),
(Position) sw->scale.image->width - 1);
- img_y = min(max((Position) floor((float) y / sw->scale.scale_y), 0),
+ img_y = min(max((Position) floor(y / sw->scale.scale_y), 0),
(Position) sw->scale.image->height - 1);
if (sw->core.visible) {
@@ -583,9 +583,9 @@ Redisplay(Widget w, XEvent *event, _X_UNUSED Region region)
img_x, img_y,
sw->scale.x + sw->scale.table.x[(int) img_x],
sw->scale.y + sw->scale.table.y[(int) img_y],
- (Dimension) ceil((float) width
+ (Dimension) ceil(width
/ sw->scale.scale_x) + 1,
- (Dimension) ceil((float) height
+ (Dimension) ceil(height
/ sw->scale.scale_y) + 1);
}
}
@@ -635,7 +635,7 @@ Precision(ScaleWidget sw)
static void
Proportional(ScaleWidget sw)
{
- float scale_x, scale_y;
+ double scale_x, scale_y;
scale_x = sw->scale.scale_y / sw->scale.aspect_ratio;
scale_y = sw->scale.scale_x * sw->scale.aspect_ratio;
@@ -651,7 +651,7 @@ Proportional(ScaleWidget sw)
else if (scale_y <= sw->scale.scale_y)
sw->scale.scale_y = scale_y;
else {
- float x_ratio, y_ratio;
+ double x_ratio, y_ratio;
x_ratio = scale_x / sw->scale.scale_x;
y_ratio = scale_y / sw->scale.scale_y;
@@ -688,12 +688,12 @@ GetScaleValues(ScaleWidget sw)
*/
sw->scale.scale_x =
- (float) max((int)(sw->core.width - 2 * sw->scale.internal_width), 1)
- / (float) sw->scale.image->width;
+ max((int)(sw->core.width - 2 * sw->scale.internal_width), 1)
+ / sw->scale.image->width;
sw->scale.scale_y =
- (float) max((int)(sw->core.height - 2 * sw->scale.internal_height), 1)
- / (float) sw->scale.image->height;
+ max((int)(sw->core.height - 2 * sw->scale.internal_height), 1)
+ / sw->scale.image->height;
}
diff --git a/ScaleP.h b/ScaleP.h
index 6449512..81bc585 100644
--- a/ScaleP.h
+++ b/ScaleP.h
@@ -78,9 +78,9 @@ typedef struct {
XtPointer userData;
Visual *visual;
/* private */
- float scale_x, scale_y;
- float aspect_ratio;
- float precision;
+ double scale_x, scale_y;
+ double aspect_ratio;
+ double precision;
GC gc;
Position x, y;
Dimension width, height;