Position of rightmost common bit in two numbers | Function to find the position of rightmost set bit in ' n ' ; Function to find the position of rightmost same bit in the binary representations of ' m ' and ' n ' ; position of rightmost same bit ; Driver program to test above
function getRightMostSetBit ( n ) { return Math . log2 ( n & - n ) + 1 ; } function posOfRightMostSameBit ( m , n ) { return getRightMostSetBit ( ~ ( m ^ n ) ) ; } let m = 16 , n = 7 ; document . write ( " " + posOfRightMostSameBit ( m , n ) ) ;