<div dir="ltr"><div><div>Micah,<br>This is because wl_fixed is a fixed-point format.  In particular, it is 24.8 fixed point meaning that the top  24 bits represent the integer part.  This means that wl_fixed effectively stores n if the number is written as the (possibly improper) fraction n/256.  In your example, 3568.005 = 913409.28 / 256.  Because wl_fixed only storres the integer n, this gets truncated to 913409/256.  When it gets converted back, this obviously does not give you the same floating-point value.<br>

</div>I hope that makes sense,<br></div>--Jason Ekstrand<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 26, 2013 at 3:40 PM, Micah Nordland <span dir="ltr"><<a href="mailto:mpnordland@gmail.com" target="_blank">mpnordland@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<br>
The value 3568.005 is not correctly converted back from fixed.<br>
The following patch to tests/fixed-test.c demonstrates. Is this<br>
expected behavior?<br>
<br>
diff --git a/tests/fixed-test.c b/tests/fixed-test.c<br>
index 739a3b1..89ec188 100644<br>
- --- a/tests/fixed-test.c<br>
+++ b/tests/fixed-test.c<br>
@@ -65,6 +65,11 @@ TEST(fixed_double_conversions)<br>
        d = wl_fixed_to_double(f);<br>
        fprintf(stderr, "fixed %x to double %lf\n", f, d);<br>
        assert(d == f / 256);<br>
+<br>
+    d = 3568.005;<br>
+    f = wl_fixed_from_double(d);<br>
+    fprintf(stderr, "fixed %x to double %lf\n", f, d);<br>
+    assert(d == wl_fixed_to_double(f));<br>
 }<br>
<br>
 TEST(fixed_int_conversions)<br>
<br>
<br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v2.0.21 (GNU/Linux)<br>
Comment: Using GnuPG with Thunderbird - <a href="http://www.enigmail.net/" target="_blank">http://www.enigmail.net/</a><br>
<br>
iQEcBAEBAgAGBQJSRJuxAAoJEPBh3Rt3H/83HkYH/2w1lrzcCNihoPp3zOrLmxao<br>
8CdSvdIHvgAWvC6mnqJx9bL7W6bqI0LrZHRgCJqKFQcvnyQq9k5k+s2Kh1C87SbQ<br>
w8KQ3B4bkRl+m4oM4mxmbeQAlHKi0+mcyu8w6bUG/8OZRvGNvfjqUW2p62MHTKUr<br>
W9Uw9cq5A30I11LV13G5enFP1JIzVJqjoVykOJd4sSRX5vdPzr+n14ThSFQ/vu8D<br>
MjpZgHvKFZ5LPkCWb0MulQc7LXAqpabJTlMlDZ56HcbqevCZ6sg1AEd6DMdKqvXi<br>
lm17vVEOOJL6SLiNruTMEyi1TFi0+B06h972VH8x9RKg1LnhLtHsfu9JjiRdLiQ=<br>
=96Vx<br>
-----END PGP SIGNATURE-----<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</blockquote></div><br></div>