On Tue, Dec 1, 2009 at 5:22 PM, Mark Dickinson <dickinsm at gmail.com> wrote: > or a workaround. E.g., for an unsigned long x, > > ((x) >= 0 ? (long)(x) : ~(long)~(x)) > > always gives the appropriate wraparound semantics (I think), assuming Sorry; should have tested. Try: ((x) <= LONG_MAX ? (long)(x) : ~(long)~(x)) Mark