整数转化为二进制原码
function y = dec2yuanma(x,N) %1<=N<=53 y=zeros(N,length(x)); for i=1:length(x) if x(i)<0 x(i)=2.^(N-1)-x(i); end d=flip(dec2bin(x(i))); b=zeros(N,1); for j=1:length(d) b(j)=str2num(d(j)); end y(:,i)=b; end end整数转化为二进制补码
function y = dec2buma(x,N) %1<=N<=53 y=zeros(N,length(x)); for i=1:length(x) if x(i)<0 x(i)=2.^N+x(i); end d=flip(dec2bin(x(i))); b=zeros(N,1); for j=1:length(d) b(j)=str2num(d(j)); end y(:,i)=b; end end