just an essay question for you

China
March 17, 2009 10:53pm CST
There are java some codes below: for (int i=0; i0;i--) { // do some work } Which is more efficient? And why?
1 person likes this
4 responses
@mr_mlk (364)
22 Jun 09
Micro-optermizations like this have no noticeable effect on the end product. Always select the most expressive option. Are you counting up or down. That is the better option.
@ruperto (1552)
• Philippines
10 Apr 09
it seems checking for i0 has an equivalent processor machine code as a single byte...(as long as i is already loaded in a register) on the other hand, checking for i
@sdk_mail (19)
• United States
5 Apr 09
if i is strictly a counter for how many times to repeat the lines, then it shouldn't matter, but many people, myself included like to use the counter in the code that is being repeated, then and only then would one or the other be more useful.
• India
5 Apr 09
I think both are equally efficient. Otherwise if you know any ew thing about this concept then share your knowledge with me as well.