On Oct 25, 7:18 pm, Gene <[EMAIL PROTECTED]> wrote:
> On Oct 24, 12:09 am, "Deepak Manohar" <[EMAIL PROTECTED]> wrote:
>
> > how abt ( ( (a & b) | (a & c) | (b & c) )<<1) + (a ^ b ^ c)
>
> how abt a + b - (-c)
Sorry my viewer hid the restrictions. Here's an answer with zero
additions. This could be written out in one expression, but I'm not
going to do that...
o1 = a ^ b ^ c; // outputs
c1 = ((a & b)|(b & c)|(a & c)) << 1; // carry-outs
// now add the carries, but these may cause ripple carries, etc.
o2 = o1 ^ c1;
c2 = (o1 & c1) << 1;
o3 = o2 ^ c2;
c3 = (o2 & c2) << 1;
... and so on ...
o32 = o31 ^ c31;
c32 = (o31 & c31) << 1;
return o32 ^ c32;
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---