Hi, On 2 May 2012 12:57, Pekka Paalanen <[email protected]> wrote: > Hmm, any reason for not doing this instead? > *p = (int32_t)trunc(d * 256.0)
Wow is that ever embarrassing. > Also, any rationale in choosing trunc() instead of round() or > ceil/floor? > > trunc() makes > 0.9 -> 0 > -0.9 -> 0 > which means the length of "zero" is double the length of any other > number. No? Thanks for the review. I've fixed this now to use trunc(foo * 256.0) or / 256.0 as appropriate, plus fixed up the sign issues. There are some tests in there now for both negative and large numbers and they seem to work fine. > Since we use double as the API type, should there not be a check for > out-of-bounds values? Perhaps even #defined min and max values apps > could use for their own additional checks. And that raises the > question, should we have a > typedef double signed_24_8; > which would seem odd at first, but make it apparent on the API > that you cannot pass just whatever doubles there? I'm not sure about the typedef, but I've at least put range handling into the marshalling code so it rejects too-large numbers. Kristian? Thanks for the review! Cheers, Daniel _______________________________________________ wayland-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/wayland-devel
