MATLAB: Conditional statement with ||

conditionalif

Say I have
If A && B && C
...do something if A = B = C = true
end
Is it faster, however to do:
If ~(A || B || C)
..do something if A or B or C = false
end
I am wondering if the latter statement is faster because it should be able break if any of the conditions are false and not test the rest. But I am wondering if the negation forces all of the conditions to be tested first?

Best Answer

If A is false, then A && B will be short-circuited. No need to use the latter approach. Use the first one because it's easy to read.