From 0e0ae7e290f28f4ee4ad807acb955d6b276d9e58 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 3 May 2023 21:16:25 +0200 Subject: [PATCH] util: simplify wl_fixed_to_double() We can just use a simple division instead of bit operations with magic numbers. Readability matters more than performance here. References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/296 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 b4cdcfa..272a3c0 100644 --- a/src/wayland-util.h +++ b/src/wayland-util.h @@ -613,14 +613,7 @@ typedef int32_t wl_fixed_t; static inline double wl_fixed_to_double(wl_fixed_t f) { - union { - double d; - int64_t i; - } u; - - u.i = ((1023LL + 44LL) << 52) + (1LL << 51) + f; - - return u.d - (3LL << 43); + return f / 256.0; } /**