Problem 511. Converting Decimal to Binary
Given a decimal number that may include a fractional component, convert it into binary representation. The numbers you are given will always be cleanly representable using positive and negative powers of 2.
As with dec2bin, return your result in a string.
Examples:
Input d = 2.5 Output b is '10.1'
Input d = 34.125 Output b is '100010.001'
Solution Stats
Problem Comments
-
2 Comments
If you really want help with this problem, put together a small test suite that gives some inputs and some sample outputs (that you tabulate by hand) and wait for someone to produce a MATLAB function to do what you want.
This is an interesting problem. Acting as an administrator, I cleaned it up and added some tests.
Solution Comments
Show commentsProblem Recent Solvers75
Suggested Problems
-
Find the alphabetic word product
3454 Solvers
-
Back to basics 23 - Triangular matrix
1115 Solvers
-
Sum of first n terms of a harmonic progression
493 Solvers
-
Detect a number and replace with two NaN's
199 Solvers
-
Relative ratio of "1" in binary number
1589 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!