CarlBK

clear,clc
a=input(\'Please input a number:\');
f=input(\'Please input the accuracy:\');
b=floor(a);
c=dec2bin(b);
d=a-b;
w=d*2;
if(d==0)
    disp(c);
else
    for i=1:f
        if(w==1)
            h(i)=1;
            break
        else if(floor(w)==1);
            h(i)=1;
            w=w-1;
            else
              h(i)=0; 
            end
       
        end
    end
end
    A=num2str(h);
    A(isspace(A))=[];
    z=strcat(c,\'.\',A);
    disp(z)

分类:

技术点:

相关文章:

  • 2021-12-23
  • 2021-12-02
  • 2021-12-29
  • 2021-04-28
  • 2021-05-24
  • 2021-10-16
猜你喜欢
  • 2021-08-03
  • 2021-12-23
  • 2021-04-13
  • 2022-01-09
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案