one's and two's complement
38 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Raza Ali
il 1 Mar 2014
Modificato: Naga viswanathreddy Siddam
il 14 Mar 2021
how to convert 8 bit binary numbers into one's and two's complement
Let a=11001011
ones_complement=00110100
twos_complement=00110101
0 Commenti
Risposta accettata
Azzi Abdelmalek
il 1 Mar 2014
Modificato: Azzi Abdelmalek
il 1 Mar 2014
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 Commenti
Naga viswanathreddy Siddam
il 11 Mar 2021
Modificato: Naga viswanathreddy Siddam
il 14 Mar 2021
How can I get reverse of the Two's complement,from a mpu 9250 sensor output!!
Più risposte (1)
MD SAMIM AKTAR
il 20 Apr 2020
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 Commenti
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!