FAQ
The relevent bit from the spec:
fixed
Signed 24.8 decimal numbers. It is a signed decimal type which offers
a sign bit, 23 bits of integer precision and 8 bits of decimal
precision. This is exposed as an opaque struct with conversion helpers
to and from double and int on the C API side.

Here's the code I have:
http://play.golang.org/p/hhnKHAtnaR
This comes from https://github.com/mortdeus/gowl
I tweaked the test so that it would fail if the conversion to and from
fixed didn't work. The conversion between int and fixed works great,
but the conversion between float64 and fixed is less than the original
value. Is this to be expected? The C code that does this for wayland
can be found here:
http://cgit.freedesktop.org/wayland/wayland/tree/src/wayland-util.h
and the test for that code is here:
http://cgit.freedesktop.org/wayland/wayland/tree/tests/fixed-test.c


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Mortdeus at Oct 1, 2013 at 7:18 pm
    I just ported `wayland/tests/fixed_test.c` to go and compared it's output
    against the official test.
    The gowl.Fixed type and the conversion functions behave the same as the
    implementation found in the main wayland library.

    I didnt add your validity tests because im thinking of implementing these
    functions in asm so we can avoid importing the "unsafe" pkg and make the
    conversions atomic.
    On Thursday, September 26, 2013 1:04:36 PM UTC-5, Micah Nordland wrote:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    The relevent bit from the spec:
    fixed
    Signed 24.8 decimal numbers. It is a signed decimal type which offers
    a sign bit, 23 bits of integer precision and 8 bits of decimal
    precision. This is exposed as an opaque struct with conversion helpers
    to and from double and int on the C API side.

    Here's the code I have:
    http://play.golang.org/p/hhnKHAtnaR
    This comes from https://github.com/mortdeus/gowl
    I tweaked the test so that it would fail if the conversion to and from
    fixed didn't work. The conversion between int and fixed works great,
    but the conversion between float64 and fixed is less than the original
    value. Is this to be expected? The C code that does this for wayland
    can be found here:
    http://cgit.freedesktop.org/wayland/wayland/tree/src/wayland-util.h
    and the test for that code is here:
    http://cgit.freedesktop.org/wayland/wayland/tree/tests/fixed-test.c
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 26, '13 at 6:04p
activeOct 1, '13 at 7:18p
posts2
users2
websitegolang.org

2 users in discussion

Micah Nordland: 1 post Mortdeus: 1 post

People

Translate

site design / logo © 2022 Grokbase