year++
1 minute read
Calvin is better at putting into words my feelings for the new year.
The difference between i++
and i = i + 1
?
Kristopher Johnson explains about this in a post written here.
i=i+1
will have to load the value ofi
, add one to it, and then store the result back toi
. In contrast,++i
may simply increment the value using a single assembly instruction, so in theory it could be more efficient.However, most compilers will optimize away the difference, and the generated code will be exactly the same.
on the same note, is 1 == 4
?
so, happy same old year!
p.s. resolutions???
I feedback.
Let me know what you think of this article by leaving a comment below!
Let me know what you think of this article by leaving a comment below!
comments powered by Disqus