中文说明:清除 clc a=dec2binPN(-16,18) ; sum = 0; sum2 = 0 ; j = 1:18 sum=sum+str2num(a(j))*2^(18-j) ; 结束 sum = sum-1 ; temp=dec2bin(sum,18) ; sum1=(-1)*str2num(temp(1)) * 2 ^17 ; i = 2:18 sum2=sum2+str2num(temp(i))*2^(18-i) ; 结束 最后 = sum2 + sum1 + 1 ;
English Description:
clear clc a=dec2binPN(-16,18); sum=0; sum2=0; for j=1:18 sum=sum+str2num(a(j))*2^(18-j); end sum=sum-1; temp=dec2bin(sum,18); sum1=(-1)*str2num(temp(1))*2^17; for i=2:18 sum2=sum2+str2num(temp(i))*2^(18-i); end final=sum2+sum1+1;