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)
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Convert the ASCII value sentence to its equivalent string
- Program to convert Hexa-Decimal Number to its equivalent BCD
- Check whether the binary equivalent of a number ends with "001" or not
- Maximum decimal equivalent possible among all connected components of a Binary Valued Graph
- Convert given integer X to the form 2^N - 1
- Convert a binary number to octal
- Convert Binary fraction to Decimal
- Python program to convert floating to binary
- Convert numbers into binary representation and add them without carry
- Convert decimal fraction to binary number
- Program to Convert Hexadecimal Number to Binary
- Minimum swaps required to convert one binary string to another
- Python program to convert decimal to binary number
- Check whether nodes of Binary Tree form Arithmetic, Geometric or Harmonic Progression
- Maximize the decimal equivalent by flipping only a contiguous set of 0s
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.