Cody

Problem 45326. Decimal Fraction to binary conversion

Solution 2795107

Submitted on 6 Aug 2020 by Rafael S.T. Vieira
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
assert(isequal(dec2bin_frac(123.25),'1111011.01'))

2   Pass
assert(isequal(dec2bin_frac(123.2,6),'1111011.001100'))

3   Pass
assert(isequal(dec2bin_frac(6.97,10), '110.1111100001'))

4   Pass
assert(isequal(dec2bin_frac(61.81250),'111101.1101'))

5   Pass
assert(isequal(dec2bin_frac(666),'1010011010'))

6   Pass
assert(isequal(dec2bin_frac(666624.5),'10100010110000000000.1'))

7   Pass
assert(isequal(dec2bin_frac(55.125,7),'110111.001'))

8   Pass
assert(isequal(dec2bin_frac(123),'1111011'))

Suggested Problems

More from this Author149

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!