problem with detzcode on machines w/64 bit longs
torek at BSDI.COM
Fri Mar 10 19:38:59 UTC 1995
>How about ... (result >> 31) ? (result | (~0L << 32)) : result
The minimum number of bits in a `long' is 32 (LONG_MIN and LONG_MAX
must be at most -2147483647 and +2147483647 respectively; the former
allows for ones-complement). The result of a shift operator is defined
if and only if the shift count does not equal or exceed the number of
bits in the type. Thus, on a machine with 32-bit ints, `~0L << 32'
More practically, on (say) a VAX, the shift instruction only looks at
the low 5 bits of the shift count, so ~0L << 32 will be ~0L => -1.
Since there is now a new ugly set of `intNN_t' typedefs in <machine/types.h>,
your best bet is probably:
More information about the tz