RE: [algogeeks] Swapping two variables without using a temporary variable

2011-06-14 Thread umesh kewat
g two variables without using a temporary variable @Wladimir: Can you kindly explain the overflow and underflow you mentioned. Thanks Supraja J On Fri, Jun 10, 2011 at 9:58 PM, Wladimir Tavares wrote: > Swapping two variables without using a temporary variable using the + and > -: > &g

Re: [algogeeks] Swapping two variables without using a temporary variable

2011-06-14 Thread Lego Haryanto
Have you tested your claim regarding overflow/underflow and proved it is indeed a problem, or you just thought that it won't work? Using two's complement, it should still work. On Friday, June 10, 2011, Wladimir Tavares wrote: > Swapping two variables without using a temporary variable using the

Re: [algogeeks] Swapping two variables without using a temporary variable

2011-06-14 Thread tech rascal
@sunny... yeah sorry, m stupid..:) thanx On Tue, Jun 14, 2011 at 10:52 AM, sunny agrawal wrote: > @tech rascal > > 10 = 01010 > 20 = 10100 > -- > xor = 0 > = 30 > why r u getting 1 ?? > > > On Tue, Jun 14, 2011 at 2:28 AM, Supraja Jayakumar < > suprajasank...@gmail.com> wrote:

Re: [algogeeks] Swapping two variables without using a temporary variable

2011-06-13 Thread sunny agrawal
@tech rascal 10 = 01010 20 = 10100 -- xor = 0 = 30 why r u getting 1 ?? On Tue, Jun 14, 2011 at 2:28 AM, Supraja Jayakumar wrote: > @Wladimir: > Can you kindly explain the overflow and underflow you mentioned. > > Thanks > Supraja J > > On Fri, Jun 10, 2011 at 9:58 PM, Wladi

Re: [algogeeks] Swapping two variables without using a temporary variable

2011-06-13 Thread Supraja Jayakumar
@Wladimir: Can you kindly explain the overflow and underflow you mentioned. Thanks Supraja J On Fri, Jun 10, 2011 at 9:58 PM, Wladimir Tavares wrote: > Swapping two variables without using a temporary variable using the + and > -: > > x = a; > y = b; > > x = x + y / / x = a + b; > y = x - y / /

[algogeeks] Swapping two variables without using a temporary variable

2011-06-11 Thread Wladimir Tavares
Swapping two variables without using a temporary variable using the + and -: x = a; y = b; x = x + y / / x = a + b; y = x - y / / y = a + b-b = a; x = x - y / / x = a + b-a = b; y = b; x = a; Problems with this approach: 1) It can cause overflow in the operation (+) 2) It can cause underflow on