Problem 49835. Decimal to Binary conversion for Large Integers
Decimal integer, a base-10 number we normally use without fractional component, can be represented as binary, a base-2 number composed either 0 or 1. The procedure to convert a decimal integer X to its binary equivalent is as follows:
- Divide X by 2. The remainder (either 0 or 1) is the first binary value.
- Divide the quotient of previous step by 2. The remainder is the next binary value.
- Repeat the process until the quotient cannot be divided anymore and so last binary is found.
As example, through process below:
Given a decimal string input x, build a function dectobin(x) that returns its binary equivalent in character array. Unlike built-in dec2bin function, your function should also work for large integers up to thousands number of digits.
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers3
Suggested Problems
-
"Low : High - Low : High - Turn around " -- Create a subindices vector
524 Solvers
-
1143 Solvers
-
Remove entire row and column in the matrix containing the input values
305 Solvers
-
convert matrix to single column
390 Solvers
-
Create the following sequence : 0 1 1 4 9 25 64 169 ...
175 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!