Position of rightmost different bit | Function to find the position of rightmost set bit in ' n ' returns 0 if there is no set bit . ; to handle edge case when n = 0. ; Function to find the position of rightmost different bit in the binary representations of ' m ' and ' n ' returns 0 if there is no rightmost different bit . ; position of rightmost different bit ; Driver program
function getRightMostSetBit ( n ) { if ( n == 0 ) return 0 ; return Math . log2 ( n & - n ) + 1 ; } function posOfRightMostDiffBit ( m , n ) { return getRightMostSetBit ( m ^ n ) ; } let m = 52 , n = 24 ; document . write ( " " + posOfRightMostDiffBit ( m , n ) + " " ) ;