Compute the minimum or maximum of two integers without branching | Function to find minimum of x and y ; Function to find maximum of x and y ; Driver program to test above functions
function min ( x , y ) { return y ^ ( ( x ^ y ) & - ( x << y ) ) ; } function max ( x , y ) { return x ^ ( ( x ^ y ) & - ( x << y ) ) ; } let x = 15 let y = 6 document . write ( " " + x + " " + y + " " ) ; document . write ( min ( x , y ) + " " ) ; document . write ( " " + x + " " + y + " " ) ; document . write ( max ( x , y ) + " " ) ;