Re: [PATCH wayland 4/5] Add support for signed 24.8 decimal numbers

2012-05-02 Thread Daniel Stone
Hi, On 2 May 2012 18:02, Kristian Høgsberg wrote: > On Wed, May 2, 2012 at 11:48 AM, Daniel Stone wrote: >> On 2 May 2012 12:57, Pekka Paalanen wrote: >>> 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

Re: [PATCH wayland 4/5] Add support for signed 24.8 decimal numbers

2012-05-02 Thread Kristian Høgsberg
On Wed, May 2, 2012 at 11:48 AM, Daniel Stone wrote: > Hi, > > On 2 May 2012 12:57, Pekka Paalanen 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 >

Re: [PATCH wayland 4/5] Add support for signed 24.8 decimal numbers

2012-05-02 Thread Daniel Stone
Hi, On 2 May 2012 12:57, Pekka Paalanen 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 mean

Re: [PATCH wayland 4/5] Add support for signed 24.8 decimal numbers

2012-05-02 Thread Bill Spitzak
On 05/02/2012 04:57 AM, Pekka Paalanen wrote: On Tue, 1 May 2012 20:30:15 +0100 Daniel Stone wrote: + u = trunc(d); + *p = u<< 8; + *p |= (uint32_t) (trunc((fabs(d - u)) * (1<< 8)))& 0xff; Hmm, any reason for not doing t

Re: [PATCH wayland 4/5] Add support for signed 24.8 decimal numbers

2012-05-02 Thread Pekka Paalanen
On Tue, 1 May 2012 20:30:15 +0100 Daniel Stone wrote: > signed_24_8 is a signed decimal type which offers a sign bit, 23 bits of > integer precision, and 8 bits of decimal precision. This is converted > to double on the C API side, as passing through varargs involves an > implicit type promotio

[PATCH wayland 4/5] Add support for signed 24.8 decimal numbers

2012-05-01 Thread Daniel Stone
signed_24_8 is a signed decimal type which offers a sign bit, 23 bits of integer precision, and 8 bits of decimal precision. This is converted to double on the C API side, as passing through varargs involves an implicit type promotion to double anyway. Signed-off-by: Daniel Stone --- src/Makefi