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>
This commit is contained in:
Haihua Hu 2025-01-06 21:55:37 +09:00
parent 9cb3d7aa9d
commit f246e619d1

View file

@ -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));
}
/**