Is the evaluation of while(n>0)
and while(n!=0)
different? Basically both are to exit in the same condition. So is there a scenario when one of them should be used? Or will it make a difference in the performance efficiency by changing the loop condition when the number of times the loop being evaluated being the same?
This depends on your platform, but in general, it will perform identically.
For example, for x86 architecture cmp
operator will be used for both >
or !=
. Here you can read more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With