thank you dave and amit... On Wed, Aug 10, 2011 at 8:36 PM, Dave <dave_and_da...@juno.com> wrote:
> @Ayswarya: In twos-complement arithmetic, -x = ~x + 1, so > > a + ~b + 1 = a +(~b +1) = a + (-b) = a - b. > > Dave > > On Aug 10, 9:23 am, Ayswarya Srinivasan <krsayswa...@gmail.com> wrote: > > can someone explain how this works- > > * > > * > > *void* *main*(){ > > *int* a,b,d; > > scanf("%d%d",&a,&b); > > d=a+~b+1; > > printf("%d",d); > > getch(); > > > > } > > > > say if a=5 b=6 then > > output is -1 > > > > if ~ is one's complement operator > > then > > a=0101 > > ~b=1001 > > > > d= 0101+1001+1. which is not -1 > > > > can someone explain how it works. > > > > -- > > > > Regards, > > Ayswarya S > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@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. > > -- Regards, Ayswarya S -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@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.