@sunny: +1 On Tue, Jul 12, 2011 at 11:11 AM, Vishal Thanki <[email protected]>wrote:
> z = x + (-y) > > :) > > On Tue, Jul 12, 2011 at 10:58 AM, Sunny T <[email protected]> wrote: > > i would say.. implementing subtraction using division and modulus is more > > costly and complicated. bit manipulation is the fastest among all > > these techniques..... > > x=a-b = (a/b)*b + a%b > > .here u are performing... totally 4 operations..1 division,1 > > multiplication,1 modulus and 1 addition.. > > > > it can be easily done by... > > > > x=a+(~b+1). this solution takes less number of operation than > > ur solution and involve less costly operators. > > > > On Tue, Jul 12, 2011 at 10:29 AM, Dave <[email protected]> wrote: > >> > >> @Chandy: Let a = 5 and b = 3. Then x = 5 - 3 = (5/3)*3 + 5%3 = 1*3 + 2 > >> = 5. Check? > >> > >> Dave > >> > >> On Jul 11, 11:38 pm, chandy jose paul <[email protected]> wrote: > >> > Y are u guys complicating things.Its as simple as this > >> > > >> > x=a-b = (a/b)*b + a%b > >> > > >> > > >> > > >> > On Tue, Jul 12, 2011 at 1:18 AM, Dave <[email protected]> > wrote: > >> > > @Aditya: Since 124 is a 3-digit number, I think it would make more > >> > > sense to use the 3-digit 10's complement of 46, i.e., 954. Then 124 > + > >> > > 954 = 1078. Since we are working in 3-digit numbers, the 1 > represents > >> > > an overflow, which you ignore. Thus, the answer is 78. > >> > > >> > > Dave > >> > > >> > > On Jul 11, 2:42 pm, aditya pratap <[email protected]> > wrote: > >> > > > suppose u want to do 124 - 46 > >> > > >> > > > step1 : write 10's complement of 46 i.e. 53 (9's complement) +1 = > 54 > >> > > > step2: add 124 + 54 = 178 > >> > > > step3: neglect 1 from 178 and answer will be 78. > >> > > >> > > > correct me if i am wrong. > >> > > >> > > > On Tue, Jul 12, 2011 at 12:54 AM, Anika Jain > >> > > > <[email protected]> > >> > > wrote: > >> > > > > how to do subtraction of two integers widout using subtractn?? > >> > > >> > > > > -- > >> > > > > 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. > >> > > >> > > > -- > >> > > > Regards > >> > > > Aditya Pratap > >> > > > MCA II > >> > > >> > > -- > >> > > 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.- Hide quoted text - > >> > > >> > - Show quoted text - > >> > >> -- > >> 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. > >> > > > > > > > > -- > > Warm Regards, > > Sunny T > > > > -- > > 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. > > > > -- > 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. > > -- 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.
