Case 2 : find the first 0 - bit index and return the Y
for ( int i = 0 ; i < len ; i ++ ) { char ch = A_binary . charAt ( len - i - 1 ) ; if ( ch == '0' ) { B = ( long ) Math . pow ( 2.0 , ( double ) i ) ; break ; } } return B ; }