conversion from double to fixed and back fails with certain values
Jason Ekstrand
jason at jlekstrand.net
Thu Sep 26 17:12:48 PDT 2013
Micah,
It simply means that you can't assume too much precision. For most things
such as pointer movement this isn't a problem because there is no good
reason why you would want to know the pointer's position more precicely
than in units 1/256 of a pixel. Recently, however, there was some
discussion of game controllers and using wl_fixed with the range [0, 1]
which is more of a problem because it restricts you to 256 (or 257
depending on how you're looking at it) values. Really, it just means you
have to be careful and make sure you think about how much precision you
need before writing protocol bits.
On the other hand, it means that you *always* know you are working with
units of 1/256 and you can always count on it. This can actually make
things much simpler in some cases. Also, it means that you don't have to
worry about encoding any floating point formats. While standard x86
processors almost all use IEEE floating point, not everything does so what
to do on those platforms becomes an issue. Also, floating point arithmetic
is fuzzy because different processors may implement rounding in slightly
different ways. (There are "standards" but they frequently get thrown to
the wind for efficiency.) By using a fixed point format, you don't have to
worry about rounding or anything like that because, if it matters, you can
simply specify it in the protocol. In short, floatin-point is nice but
provides very few guarantees; fixed-point isn't so nice but you always know
exactly what you're working with.
--Jason Ekstrand
On Thu, Sep 26, 2013 at 6:59 PM, Micah Nordland <mpnordland at gmail.com>wrote:
> OK, I are there any parts of the Wayland spec where this might cause
> problems/make things interesting?
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20130926/6b0e2f62/attachment.html>
More information about the wayland-devel
mailing list