Pedro Pedruzzi <pedro.pedru...@gmail.com> writes: > On Thu, Oct 6, 2011 at 11:04 AM, Miles Bader <mi...@gnu.org> wrote: >> How about: >> >> bool overflowbit2(unsigned int a, unsigned int b) >> { >> const unsigned int sum = a + b; >> return ~(a ^ b) & sum & 0x80; >> } > > Miles, it is not the same. Take for example (0xff, 0xff). In 8-bit > 2's complement, this is (-1, -1) and does not overflow. Your > function says it does.
Negative overflow isn't considered overflow...? wacky... -miles -- ===== (^o^; (())) *This is the cute octopus virus, please copy it into your sig so it can spread.