Position of rightmost bit with first carry in sum of two binary | C # implementation to find the position of rightmost bit where a carry is generated first ; 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
using System ; class GFG { static int posOfRightmostSetBit ( int n ) { return ( int ) ( Math . Log ( n & - n ) / Math . Log ( 2 ) ) + 1 ; } static int posOfCarryBit ( int a , int b ) { return posOfRightmostSetBit ( a & b ) ; } public static void Main ( ) { int a = 10 , b = 2 ; Console . Write ( posOfCarryBit ( a , b ) ) ; } }