Author: Tom Likens
Date: 08:19:04 07/20/03
Go up one level in this thread
On July 20, 2003 at 10:52:52, Omid David Tabibi wrote: >On July 20, 2003 at 10:24:00, Vladimir Elin wrote: > >>I'm not sure too, but in my program I used ++i. > >It is a good practice to use ++i instead of i++, but I prefer the latter (just a >habit). > >Anyway, I think both of them should translate to a simple asm instruction > >inc eax > >so, no practical difference. The only difference is that i++ returns a copy of i, while ++i does not. For native types (integers etc.) it usually makes no difference, since any decent optimizer will get rid of the extra copy. It *can* be important in C++ if you are incrementing an object since the extra copy will require a constructor, destructor and copy call, which may not be optimized away. regards, --tom
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.