?? convert10to2.m
字號:
function y=convert10to2(x)
% 本函數實現十進制數到二進制數的轉換
%x為輸入十進制數,y為輸出二進制數
y = zeros(1,5);
if x>2^5-1
l = floor(log2(x));
l=l+1;
temp = zeros(1,l);
for i=1:l
temp(i) = mod(x,2);
x = (x-temp(i))/2;
end
k = 6;
for i=l:-1:k
temp(i-k+1:i-1) = temp(i-k+1:i-1)+temp(i)*[1 0 1 0 0];
temp(i)=0;
temp = mod(temp,2);
end
y = temp(1:k-1);
else
for i =1:5
y(i) = mod(x,2);
x = (x-y(i))/2;
end
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -