Answer the question
In order to leave comments, you need to log in
How much MK is loaded when checking a long condition?
Good afternoon. Prompt whether it is effective to use one long condition? Or break it down into smaller pieces. MK freescale kinetis kl25 cortex - m0+
As an example (x1 >= n <= x2 && x3 > x4)
Answer the question
In order to leave comments, you need to log in
Arms (as well as, probably, all other processors) anyway cannot compare more than two numbers. In any case, this condition will be broken by the compiler into several.
Sometimes you need to read textbooks on the programming language in which you write
. Previously, your question would have been relevant, with old compilers, but now the code
int I;
I = I + 1;
if(I < 5){ }
int I;
if(++I < 5){ }
Despite the fact that the compiler will break the condition into several comparisons, the calculations will be performed completely, because, EMNIP, there are no lazy evaluations in C. In your case, if the first condition is false, it makes no sense to calculate the second value, and therefore, you can break the condition into nested ifs.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question