sorry its the same cause you Xored a with b again On 29 June 2010 15:21, shrinivas <shri.nit...@gmail.com> wrote:
> hi friends i m new to this group, i found very interesting and useful > discussion here.... > this is code for adding two number without arithmetic operator > > int add(int a, int b) > { > do > { > a=a^b; > b=(a^b)&b; > b=b<<1; > } while(b); > > return(a); > } > > > it is working well for negative numbers also . i tried lot but can not > understand logic behind it can any one explain it in easy manner ... > thanks in advance > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Thanks & Regards, Priyanka Chatterjee Final Year Undergraduate Student, Computer Science & Engineering, National Institute Of Technology,Durgapur India http://priyanka-nit.blogspot.com/ -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.