c - i++, i=i+1 and i+=1 which one is faster? -


this question has answer here:

i'm curious know 1 run fastest in cpu among i++, i+=1 , i=i+1 , how can measure execution time?

well, @ first mankind invented following record.

i = i+1;  

then along achievments in hardware mainkind invented following record

i += 1; 

and @ last due progress in computer sciences mankind invented following records

++i; 

and

i++; 

all these 3 forms of records expressions of same set of machine instructions.(with minor exception ++i , i++ when parts of more complex expression):) , set of machine instructions not depend on level of compiler optimization.:)

p.s. of course discussing these operators fundamentals types. there no sense discuss these operators user-defined types because can overloaded in various ways.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -