I am curious to know the computing speed difference between n++ and n=n+1 in C. I found a rather lengthy discussion on Stack Overflow, where some people are literally contradicting each other.

To summarize briefly for the nonspecialist, my interpretation is the following:

  1. With modern compilers the speed difference is not worth worrying about.
  2. Most people these days use the suffix increment operator n++ and not n=n+1.

Am I right?

  • Am I right? uma1966
    – uma1966
    Commented Jul 10, 2014 at 22:41
  • Well, I agree with the opinion that says no difference at all except that n++ is shorter, faster to right and looks good!
    – kzidane
    Commented Jul 10, 2014 at 22:43

1 Answer 1


Actual compilers perform a lot of optimizations while compiling the code.

Older compilers and processors treated n++ and n=n+1 in different ways, producing a faster code for the first expression using register access instead of memory access.

  • 1
    What about the precedence of prefix and postfix increment/decrement operator is greater than addition(+) and subtraction(-)?
    – sinister
    Commented Aug 2, 2014 at 3:06
  • 1
    Yes, the precedence is greater, but it does not affect the speed of the code.
    – Cygni_61
    Commented Aug 2, 2014 at 7:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .