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 <contact@emersion.fr>
This commit is contained in:
Simon Ser 2023-05-03 21:16:25 +02:00
parent 11b17c1286
commit 0e0ae7e290

View File

@ -613,14 +613,7 @@ typedef int32_t wl_fixed_t;
static inline double static inline double
wl_fixed_to_double(wl_fixed_t f) wl_fixed_to_double(wl_fixed_t f)
{ {
union { return f / 256.0;
double d;
int64_t i;
} u;
u.i = ((1023LL + 44LL) << 52) + (1LL << 51) + f;
return u.d - (3LL << 43);
} }
/** /**