Given a BCD (Binary Coded Decimal), the task is to convert this to its equivalent Binary number.
Integer value of the given BCD is 48(0100 -> 4, 1000 -> 8).
(48)10 = (110000)2
Approach: In order to solve this problem we need to split the given BCD number into binary chunks of length 4 and convert them to integer one by one to generate the final integer representation of the given BCD. Once generated, convert the integer to its binary form.
Below is the implementation of the above approach.
Time Complexity: O(N) where N denotes the length of the BCD string provided
Auxiliary Space: O(1)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program to convert Hexa-Decimal Number to its equivalent BCD
- Convert a given Decimal number to its BCD representation
- Convert the ASCII value sentence to its equivalent string
- Decimal Equivalent of Gray Code and its Inverse
- Program to Convert BCD number into Decimal number
- Program to convert a BCD to Hexa-Decimal Number
- Check whether the binary equivalent of a number ends with given string or not
- BCD or Binary Coded Decimal
- Maximum decimal equivalent possible among all connected components of a Binary Valued Graph
- Check whether the binary equivalent of a number ends with "001" or not
- BCD addition of given Decimal numbers
- Minimum flips required to form given binary string where every flip changes all bits to its right as well
- Maximize the decimal equivalent by flipping only a contiguous set of 0s
- Convert given integer X to the form 2^N - 1
- Find N numbers such that a number and its reverse are divisible by sum of its digits
- Smallest N digit number with none of its digits as its divisor
- Count of Array elements greater than all elements on its left and at least K elements on its right
- Count of Array elements greater than all elements on its left and next K elements on its right
- Reduce the fraction to its lowest form
- Check if binary representation of a given number and its complement are anagram
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.