User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 401,549 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,545 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.

C++ Performance Tips

Join Date: Apr 2007
Posts: 6
Reputation: kmillen is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kmillen kmillen is offline Offline
Newbie Poster

Re: C++ Performance Tips

  #31  
Jul 12th, 2007
Using an example will help.
For instance let a = 6 and b = 13.

a = a + b
Now a = 19 and b is unchanged at 13.

b - a - b or b = 19 - 13
Now a = 19 (unchanged) and b = 6.

a = a - b or a = 19 - 6
Now a = 13 and b = 6. The values are swapped.

For pure functionality, I don't recommend this method because it only works with summable values. Swapping using a temporary variable works in all cases.
Reply With Quote  
All times are GMT -4. The time now is 3:31 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC