March 10, 1995
noon
However, not all operating systems have [int32_t] ... Probably a case for #ifdef'ing the code.
Hm, good point, I was thinking of BSD systems specifically. (It is these `soma' muscle relaxant pills! I swear! :-) ) If one is to resort to #ifdef's, the original suggestion of testing the top bit and OR'ing in ~0L << 32 should work, using something like: #if LONG_MAX > 2147483647 /* long > 32 bits */ if (result & (1L << 31)) result |= ~0L << 32; #endif return (result); The (long)(int32_t) method may produce better code on an Alpha, Chris