I want to add two binary numbers 11111101 and 0.1000, please help me..

4 次查看(过去 30 天)
i tried number of functions but m not able to add these to numbers

回答(1 个)

Stephen23
Stephen23 2017-8-25
>> binf2dec('11111101')+binf2dec('0.1')
ans =
253.5
Where
function dec = binf2dec(bin)
tkn = regexp(bin,'^([01]+)\.?([01]*)$','tokens','once');
vec = [tkn{:}]-'0';
dec = sum(vec.*pow2((numel(vec):-1:1)-1-numel(tkn{2})));
end

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by