one's and two's complement
38 ビュー (過去 30 日間)
古いコメントを表示
Raza Ali
2014 年 3 月 1 日
編集済み: Naga viswanathreddy Siddam
2021 年 3 月 14 日
how to convert 8 bit binary numbers into one's and two's complement
Let a=11001011
ones_complement=00110100
twos_complement=00110101
0 件のコメント
採用された回答
Azzi Abdelmalek
2014 年 3 月 1 日
編集済み: Azzi Abdelmalek
2014 年 3 月 1 日
a='11001011';
c1=not(a-'0') % one's complement
d=1;
for k=numel(a):-1:1
r=d & c1(k);
c2(1,k)=xor(d,c1(k)); % c2 is two's complement
d=r;
end
[c1;c2]
3 件のコメント
Naga viswanathreddy Siddam
2021 年 3 月 11 日
編集済み: Naga viswanathreddy Siddam
2021 年 3 月 14 日
How can I get reverse of the Two's complement,from a mpu 9250 sensor output!!
その他の回答 (1 件)
MD SAMIM AKTAR
2020 年 4 月 20 日
a='11001011';
c1=not(a-'0') % one's complement
d=1;
for k=numel(a):-1:1
r=d & c1(k);
c2(1,k)=xor(d,c1(k)); % c2 is two's complement
d=r;
end
[c1;c2]
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!