Branch-less abs()

Here’s a little tip I’d like to preserve for posterity, shown to me by my colleague Jon.

A branche-less abs algorithm for 32 bit integers that doesn’t depend on an abs processor instruction:

int tmp = a >> 31;
a ^= tmp;
a -= tmp;