Subtraction With 8 Bit Integers

1.6k Views Asked by At

I have encountered the following question and I don't know how to approach it:

"Perform the following subtraction by adding the 2's complement using 8 bit integers: 35-15=20"

1

There are 1 best solutions below

0
On BEST ANSWER

You are asked to do $35 +(-15)$ representing the numbers in twos complement. For positive numbers, the numeral in twos complement is the same as the binary number, so $35$ is represented as $0010\ 0011_2$ in eight bits. To make a number negative, you complement it bitwise, then add one. To represent $15$ we note that $15$ is represented as $0000\ 1111_2$. Its bitwise complement is $1111\ 0000_2$ so $-15$ is represented as $1111\ 0001$. We then add $0010\ 0011_2+1111\ 0001_2=0001\ 0100_2=20_{10}$