Tag Archives: binary-representation

Convert Binary fraction to Decimal

Given an string of binary number n. Convert binary fractional n into it’s decimal equivalent. Input: n = 110.101 Output: 6.625 Input: n = 101.1101 Output: 5.8125 We strongly recommend that you click here and practice it, before moving on to the solution. Following are the steps of converting binary fractional to decimal. A) Convert… Read More »

1’s and 2’s complement of a Binary Number

Given a Binary Number as string, print its 1’s and 2’s complements. 1’s complement of a binary number is another binary number obtained by toggling all bits in it, i.e., transforming the 0 bit to 1 and the 1 bit to 0. Examples: 1’s complement of “0111” is “1000” 1’s complement of “1100” is “0011”… Read More »

Add two bit strings

Given two bit sequences as strings, write a function to return the addition of the two sequences. Bit strings can be of different lengths also. For example, if string 1 is “1100011” and second string 2 is “10”, then the function should return “1100101”.