Branchless Programming: Difference between revisions

Line 57: Line 57:
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
x = x + (20 * (age > 10) - 10);
x = x + (20 * (age > 10) - 10);
# or
// or
y = age > 10;
y = age > 10;
x = x + 10 * y - 10 * (1-y);
x = x + 10 * y - 10 * (1-y);