It is used to increment a value by 1. If using post-increment such as i++ this is evaluated after the rest of the code line is. Any other opinions? thanks. (note: no move between, so no reason to do this). In this post, we’ll learn how pre-increment and post-increment operators work in programming. If you didn't understand until now, I go a bit further (sry for my english): So the second loop is more performant for no quality loss. Measure, don't guess. What's the difference between 'war' and 'wars'. How do I loop through or enumerate a JavaScript object? I notice that when i do a pre-increment, the execution time is lesser that when i do the post-increment. And there is no way you can claim ++i should use instead of i++, it is up to the logic we are going to handle. (++b). If you use POST-increment, the variable "i" will be cached, before it will get incremented! The post-increment version of the operator overloading returns a new temporary object, so it has to build it and copy it; thus, it should be slower. @pattmorter huh... no, it increments from 0 to 10 in both cases, then exits the loop because 10 >= 10. Increment operator is used to increment the current value of variable by adding integer 1. Post-increment and pre-increment (or decrement) basically means if you are using pre-increment such as ++i this is evaluated before the rest of that code line is. Nano-optimizations like this usually don't make a measurable difference. Join Stack Overflow to learn, share knowledge, and build your career. Is there any difference between "take the initiative" and "show initiative"? Any suggestions on why this might be the case ? There should be no difference.... could because of the fact that post increment requires extra copy. Looking for title/author of fantasy book where the Sun is hidden by pollution and it is always winter. your coworkers to find and share information. When ++ or — used before the operand like ++x, –x, then we call it as Java prefix. How to increase the byte size of a file without affecting content? Stack Overflow for Teams is a private, secure spot for you and Draw horizontal line vertically centralized. I doubt that this will matter, even if you're doing extremely heavy scientific calculations. Assuming you are talking about the C like syntax: ++i - Pre-Increment i++ - Post Increment Then the difference is in the order of the 2 operations combined - “Increment” & “Take the value of”. Revision 2 of this test case created by markus on 2013-5-16. In the pre increment the value is incremented at first, then used inside the expression. Exporting QGIS Field Calculator user defined function. @MarkoTopolnik: Will JIT always do it, or just for a large number of iterations? This lecture explains the concept of Post and Pre Increment Operators. Is there a resource anywhere that lists every spell and the classes that can use them? What was your test case where the time was less? So the value of b is first incremented from 2 to 3 and then assigned to c . What's the difference between 'war' and 'wars'? The pre increment operator is used to increment the value of some variable before using it in an expression. for (int i=0; i