Branchless is a Go package that provides branchless operations on integers. It assumes int
is 64-bit so will not work correctly on 32-bit architecture.
Returns the minimum of x and y.
Returns the maximum of x and y.
Returns 0 if x is less than 0, otherwise x.
Returns 1 if x < y, otherwise 0.
Returns 1 if x > y, otherwise 0.
Returns 1 if x == y, otherwise 0.
Returns 1 if x != y, otherwise 0.
Returns 1 if x <= y, otherwise 0.
Returns 1 if x >= y, otherwise 0.
Returns the absolute value of x.
Returns the absolute difference between x and y.
Returns -1 if x < 0, 0 if x == 0, and 1 if x > 0.
Returns 1 if x > 0, otherwise 0.
Returns 1 if x < 0, otherwise 0.
Returns 1 if x == 0, otherwise 0.
Returns 1 if x != 0, otherwise 0.
Clamps the value x between the minimum (min) and maximum (max) values.
Returns 1 if x is a power of 2 (or is zero), otherwise 0.
Returns 1 if x is even, otherwise 0.
Returns 1 if x is odd, otherwise 0.
Returns the negation of x.
Returns 1 if x is divisible by y, otherwise 0.