For subtraction we can use the same add function
int add(int a, int b)
{
while (a) {
a = (a & b) << 1;
b = a^b;
}
return b;
}
int sub(int a, int b) // add a with b's 2's
complement.
{
return (add(a, add(~b, 1)));
}
On Sat, Aug 20, 2011 at 11:34 PM, priya ramesh <
[email protected]> wrote:
> +1 sagar!
>
> --
> 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?hl=en.
>
--
With regards
............
Puneet Chawla
Computer Engineering Student
NIT Kurukshetra
--
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?hl=en.