Find the number obtained after concatenation of binary representation of M and N | Utility function to calculate binary length of a number . ; Function to concatenate the binary numbers and return the decimal result ; Find binary length of n ; left binary shift m and then add n ; Driver code
function getBinaryLength ( n ) { let length = 0 ; while ( n > 0 ) { length += 1 ; n = parseInt ( n / 2 , 10 ) ; } return length ; } function concat ( m , n ) { let length = getBinaryLength ( n ) ; return ( m << length ) + n ; } let m = 4 , n = 5 ; document . write ( concat ( m , n ) ) ;