Performance: greater / smaller than vs not equal to

前端 未结 7 1551
礼貌的吻别
礼貌的吻别 2020-12-14 14:47

I wonder if there is a difference in performance between

checking if a value is greater / smaller than another

for(int x = 0; x <         


        
相关标签:
7条回答
  • 2020-12-14 15:30

    The performance in theory is the same. When you do a less than or not equal to operation, in the processor level you actually perform a subtract operation and check if the negative flag or zero flag is enabled in the result. In theory the performance will be the same. Since the difference is only checking the flag set.

    0 讨论(0)
提交回复
热议问题