While looking through some example C code, I came across this:
y -= m < 3;
What does this do? It it some kind of condensed for loop or som
If you break it down by order of precedence for each operation, you get:
y = (y - (m < 3));
m < 3
gets evaluated and returns a boolean result 1
or 0
, so the expression can be simplified as
y = y - 1; // if m < 3 is true
or
y = y - 0; // if m < 3 is false
The purpose for doing this is to avoid an if
clause.