+ 4

Which one is faster i=i+1 or i++

i=i+1 and i++ both will increment i by one but in compiler prospective which one is faster i know answer try to answer it

12th Mar 2017, 2:58 PM
Swamy Kanuri
Swamy Kanuri - avatar
9 Respostas
+ 17
++i can be faster than either of the other 2 😎 Dunno exactly why though, just is
12th Mar 2017, 4:08 PM
Jafca
Jafca - avatar
+ 15
i++ is a increment operator it takes less load then i=i+1as it consume less time and space in compilation process
12th Mar 2017, 3:09 PM
Mansi Dagla
Mansi Dagla - avatar
+ 5
i++ is faster because they return value before. then increment,maybe....
12th Mar 2017, 3:06 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 5
Oh yeah.Why I didn't think like that? @Swamy
12th Mar 2017, 3:17 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 4
In practical terms the difference isn't worth the time it takes to discuss it.
12th Mar 2017, 4:29 PM
Abner Schmidt
Abner Schmidt - avatar
+ 1
I++ is faster!
12th Mar 2017, 3:02 PM
winkyihtut
winkyihtut - avatar
+ 1
yes' very hard" but technically speaking it is matter of mechine cycle's i=i+1 will take 2 mechine cycle's means 24 clock cycles but i++ take one mechine cycle 12 clock cycles so it is faster in execution when compared to other this same is applicable for other pre and post Inc/Dec instructions
12th Mar 2017, 3:14 PM
Swamy Kanuri
Swamy Kanuri - avatar
0
good winkyihtut but what is reason behind it??could you explain for me
12th Mar 2017, 3:03 PM
Swamy Kanuri
Swamy Kanuri - avatar
0
actually i got this question in an interview that's why i know @ very hard
12th Mar 2017, 3:21 PM
Swamy Kanuri
Swamy Kanuri - avatar