This code computes the minimum or maximum of two values without doing any branching. Because modern CPUs try and fetch instructions before they execute, and despite branch prediction code, branchless code still runs a bit faster.
int x; // we want to find the minimum of x and y
int r; // the result goes here
r = y + ((x - y) & -(x < y)); // min(x, y)
r = x - ((x - y) & -(x <>