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.


 Input  d = 2.5
 Output b is '10.1'
 Input  d = 34.125
 Output b is '100010.001'

Solution Stats

42.74% Correct | 57.26% Incorrect
Last solution submitted on Oct 20, 2016

Problem Comments

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more