Position of rightmost bit with first carry in sum of two binary | Function to find the position of rightmost set bit in ' n ' ; Function to find the position of rightmost bit where a carry is generated first ; Driver code
function posOfRightmostSetBit ( n ) { return parseInt ( Math . log ( n & - n ) / Math . log ( 2 ) ) + 1 ; } function posOfCarryBit ( a , b ) { return posOfRightmostSetBit ( a & b ) ; } var a = 10 , b = 2 ; document . write ( posOfCarryBit ( a , b ) ) ;