Ulf Magnusson <ulfali...@gmail.com> writes:
> Might as well do
>
> bool overflowbit(unsigned int a, unsigned int b) {
>     const unsigned int sum = a + b;
>     return (a ^ b) & ~(a ^ sum) & 0x80;
> }
>
> But still not very good output compared to other approaches as expected.

How about:

   bool overflowbit2(unsigned int a, unsigned int b)
   {
       const unsigned int sum = a + b;
       return ~(a ^ b) & sum & 0x80;
   }

?

I thinnnnk it has the same results as your function...
[I just made a table of all 8 possibilities, and checked!]

-miles

-- 
Circus, n. A place where horses, ponies and elephants are permitted to see
men, women and children acting the fool.

Reply via email to