On Thu, Mar 08, 2001 at 11:43:31AM -0500, Dan Sugalski wrote:
> I was thinking maybe (length/4)*31-bit 2s complement to make portable 
> overflow detection easier, but that would be only if there wasn't a good C 
> library for this available to snag.

The only portable integer overflow in ANSI C is unsigned integers.
signed integer overflow does not always do what you might expect, even
on a 2s complement machine.
[I wasted a lot of Helmut Jarusch's time finding this out. 32 bit signed
integers don't set flags in the way you would expect on 64 bit Irix
when the signed integers overflow. It's undefined by ANSI, so it's legal.
(Thanks Helmut for persevering until we tracked this one down)


Nicholas Clark

Reply via email to