I'm curious... why is the cls_wire->increment.frac getting cast to unsigned int? It's already typed as uint32_t.
Looking at the context a bit more, I agree with Jamey that this should work (with or without explicit casts): cls_lib->increment = (double)cls_wire->increment.integral; cls_lib->increment += ldexp((double)cls_wire->increment.frac, -32); But I think it would be more useful to provide something like this in the proto to help with conversion: static inline double fp1616_to_double(FP1616 in) { double ret; ret = (double)(in >> 16); ret += ldexp((double)(in & 0xff), -16); return ret; } static inline double fp3232_to_double(FP3232 in) { double ret; ret = (double)in.integral; ret += ldexp((double)in.frac, -32); return ret; } static FP1616 double double_to_fp1616(double in) { FP1616 ret; int32_t integral double frac_f; uint32_t frac_d; integral = (int32_t)in << 16; frac_f = in - (double)((int32_t)(in)); if (fabs(frac_f) < 0) { frac_d = (uint32_t)ldexp(frac_f,16); } else { /* crap */ frac_d = 0; } ret = integral << 16; ret |= frac & 0xff; return ret; } static FP3232 double double_to_fp3232(double in) { FP3232 ret; int32_t integral double frac_f; uint32_t frac_d; integral = (int32_t)in << 16; frac_f = in - (double)((int32_t)(in)); if (fabs(frac_f) < 0) { frac_d = (uint32_t)ldexp(frac_f,16); } else { /* crap */ frac_d = 0; } ret.integral = integral; ret.frac = frac_d; return ret; } On Sep 19, 2011, at 5:37 PM, Jamey Sharp wrote: > I'm a bit skeptical... Would ldexp(frac, -32) work for you? Otherwise > I'd argue for (UINT64_C(1) << 32). > > Jamey > > On Tue, Sep 20, 2011 at 10:19:54AM +1000, Peter Hutterer wrote: >> Reported-by: Jeremy Huddleston <jerem...@apple.com> >> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> >> --- >> something like this good enough? >> >> src/XExtInt.c | 2 +- >> 1 files changed, 1 insertions(+), 1 deletions(-) >> >> diff --git a/src/XExtInt.c b/src/XExtInt.c >> index d74a8d4..4009285 100644 >> --- a/src/XExtInt.c >> +++ b/src/XExtInt.c >> @@ -1577,7 +1577,7 @@ copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int >> *nclasses) >> cls_lib->scroll_type= cls_wire->scroll_type; >> cls_lib->flags = cls_wire->flags; >> cls_lib->increment = cls_wire->increment.integral; >> - cls_lib->increment += (unsigned >> int)cls_wire->increment.frac/(double)(1UL << 32); >> + cls_lib->increment += (unsigned >> int)cls_wire->increment.frac/(double)(1ULL << 32); >> >> to->classes[cls_idx++] = any_lib; >> } >> -- >> 1.7.6 >> >> _______________________________________________ >> xorg-devel@lists.x.org: X.Org development >> Archives: http://lists.x.org/archives/xorg-devel >> Info: http://lists.x.org/mailman/listinfo/xorg-devel _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel