GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  OOPS
Go To First  |  Previous Question  |  Next Question 
 OOPS  |  Question 41 of 258    Print  
Why preincrement operator is faster than postincrement?

  
Total Answers and Comments: 3 Last Update: September 17, 2009   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
August 30, 2005 06:54:31   #1  
Ruth Samuel        

RE: Why preincrement operator is faster than postincrement?
Preincrement can be faster on systems where the increment can not begin until the comparison is complete -such as a Pentium. The P6 core can use register aliasing to start the increment (using 'load effective address' so as not to ruin the comparison test).
 
Is this answer useful? Yes | No
December 30, 2006 16:08:57   #2  
GAURAV MODY        

RE: Why preincrement operator is faster than postincr...

the pre inc operator increments the value of that particular variable on that line itself

the post inc operator increments the value of that particular variable after going on the next line

in simple words

eg.

e 5; on this line value of e 5

e++; on this line value of e 5

++e; on this line value of e 7.

gaurav mody.


 
Is this answer useful? Yes | No
September 17, 2009 01:02:37   #3  
Freighter Member Since: September 2009   Contribution: 1    

RE: Why preincrement operator is faster than postincrement?
"Postincrement is usually less efficient than preincrement because it has to remember & return its original value"

That is apart from also doing the increment operation Postincrement has to remember & return its original value.

Exceptional C++ Herb Sutter Item #6 p19

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape