testing test
Member level 3

Hi,
I want to find the 2's complement of -127 in MATLAB for 8 bits. I want to find 2's complement of a. So, I multiply it by -1 and takes its dec2bin:
Now b = '01111111'
I want to invert all the bits of b and add 1 to it. How can I do it?
Thank you.
I want to find the 2's complement of -127 in MATLAB for 8 bits. I want to find 2's complement of a. So, I multiply it by -1 and takes its dec2bin:
Code:
a=-127
a=-1*a;
b=dec2bin(a,8);
Now b = '01111111'
I want to invert all the bits of b and add 1 to it. How can I do it?
Thank you.