Answer the question
In order to leave comments, you need to log in
Which check is faster?
if(variable >= 300)
vs if(variable > 299)
and if(variable != 200)
vsif(variable < 200)
Answer the question
In order to leave comments, you need to log in
Which check is faster?
no difference, because a mathematical comparison operation is one processor instruction.
even on the weakest computers there is no difference in the speed of these checks
in the interpreter they work faster with one character, in the compiler there is no difference: there are single processor instructions for this type of setting operation.
It all depends on the compiler used, and the specified settings. For example, the compiler can
expand the line into
add eax, 5 //в eax - переменная v
cmp eax, 200
jl label1
add eax, 5
jge short label1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question