aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaihua Hu <jared.hu@nxp.com>2025-01-06 21:55:37 +0900
committerHaihua Hu <jared.hu@nxp.com>2025-01-09 09:58:32 +0900
commitf246e619d17deb92f414315d1747a9b7aca659b9 (patch)
treea86c55604e209fb1404d860aa31a3069e72c34d8
parentconnection: Fix wrong format string (diff)
downloadwayland-f246e619d17deb92f414315d1747a9b7aca659b9.tar
wayland-f246e619d17deb92f414315d1747a9b7aca659b9.tar.gz
wayland-f246e619d17deb92f414315d1747a9b7aca659b9.tar.bz2
wayland-f246e619d17deb92f414315d1747a9b7aca659b9.tar.lz
wayland-f246e619d17deb92f414315d1747a9b7aca659b9.tar.xz
wayland-f246e619d17deb92f414315d1747a9b7aca659b9.tar.zst
wayland-f246e619d17deb92f414315d1747a9b7aca659b9.zip
util: reduce error of wl_fixed_from_double()
when cast double to fixed pointer, there will be big error, eg 1919.9998 to 1919. Call round before cast to get nearest value 1920 of 1919.9998 Signed-off-by: Haihua Hu <jared.hu@nxp.com>
-rw-r--r--src/wayland-util.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/wayland-util.h b/src/wayland-util.h
index 929a34f..4edec8b 100644
--- a/src/wayland-util.h
+++ b/src/wayland-util.h
@@ -635,7 +635,7 @@ wl_fixed_to_double(wl_fixed_t f)
static inline wl_fixed_t
wl_fixed_from_double(double d)
{
- return (wl_fixed_t) (d * 256.0);
+ return (wl_fixed_t) (round(d * 256.0));
}
/**