From 2a91f01d6c617f8f2bd1c5bf18cfa9bd21a732f6 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 26 Oct 2023 18:28:25 +0200 Subject: [PATCH] util: simplify wl_fixed_from_double() Same as 0e0ae7e290f2 ("util: simplify wl_fixed_to_double()"), but for the reverse function. Signed-off-by: Simon Ser --- src/wayland-util.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/wayland-util.h b/src/wayland-util.h index 272a3c0..1a451e4 100644 --- a/src/wayland-util.h +++ b/src/wayland-util.h @@ -626,14 +626,7 @@ wl_fixed_to_double(wl_fixed_t f) static inline wl_fixed_t wl_fixed_from_double(double d) { - union { - double d; - int64_t i; - } u; - - u.d = d + (3LL << (51 - 8)); - - return (wl_fixed_t)u.i; + return (wl_fixed_t) (d * 256.0); } /**