According to the logic design
Comparator of "<" or ">" would need a lot of adders
But "==" or "!=" would be cheaper than "<" or ">"
If this is true, why most of the programmer still keen to "<" or ">" in for loop?
Do I make any mistake?
Thanks a lot
anyway, (for integers) for comparison a function cmp a, b is used. It basically performs subtraction, but does not modify it's arguments. This function sets the flags that show whether a > b, a == b or a < b. What the operators do in c++ is call cmp and then check the appropriate flag, so the process is exactly the same.
There's no difference in cycle cost with modern processors and compilers always have transformed simple/obvious loops so that comparison for equality is used, even if you used the < operator.