Check this solution if it helps you
quoting below code from above reference
int x; // we want to find the minimum of x and y
int y;
int r; // the result goes here
r = y ^ ((x ^ y) & -(x < y)); // min(x, y)
One more trick under same heading is
r = y + ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))); // min(x, y)
You can remove -1 from trick 2. It works only on some systems and is not portable.
You can extend this idea to find minimum of 3 numbers.
static inline int min3(int x, int y, int z)
{
register int r, d;
d = x - y;
r = y + (d & (d >> (sizeof(int) * CHAR_BIT))); /* add -1 if required */
d = r - z;
r = z + (d & (d >> (sizeof(int) * CHAR_BIT))); /* add -1 if required */
return r;
}
If range of your numbers is very less, you can even use some look up, or more efficient but hack.