Discover the best answers to your questions with the help of IDNLearn.com. Our community provides accurate and timely answers to help you understand and solve any issue.

Subtraction using 1's and 2's complement:

(i) [tex](52)_{10} - (5)_{10}[/tex]

(ii) [tex](101011)_2 - (11010)_2[/tex]


Sagot :

Sure, let’s dive into the problem step by step. We will perform subtraction using 2's complement for both decimal and binary numbers.

### Part (i) Decimal subtraction using 2's complement

We need to subtract [tex]\(5_{10}\)[/tex] from [tex]\(52_{10}\)[/tex].

1. Step 1: Convert both numbers to the same bit-width of binary form.
- [tex]\(52_{10}\)[/tex] in binary is [tex]\(110100_2\)[/tex].
- [tex]\(5_{10}\)[/tex] in binary is [tex]\(000101_2\)[/tex] using 6 bits to match the bit-width of 52.

2. Step 2: Find the 2's complement of the second number (000101).
- Find the 1's complement by flipping the bits: [tex]\(000101_2 \rightarrow 111010_2\)[/tex].
- Add 1 to the 1's complement: [tex]\(111010_2 + 1 = 111011_2\)[/tex].
- Thus, the 2's complement of [tex]\(5_{10}\)[/tex] is [tex]\(111011_2\)[/tex].

3. Step 3: Add the original number to the 2's complement of the second number.
- [tex]\(110100_2\)[/tex] (52 in binary)
- [tex]\(+ 111011_2\)[/tex] (2's complement of 5)
- [tex]\(\hline\)[/tex]
- [tex]\( 110100_2\)[/tex]
- [tex]\(+111011_2\)[/tex]
- [tex]\(\hline\)[/tex]
- [tex]\( 1100111_2 \)[/tex] (with carry)

4. Step 4: Discard any carry beyond the original bit-width.
- We initially used 6 bits.
- So, the resultant binary is [tex]\(100111_2\)[/tex], discarding the leftmost bit.

5. Step 5: Convert the result back to decimal.
- [tex]\(100111_2\)[/tex] equals [tex]\(39_{10}\)[/tex].

Hence, the result is [tex]\( 52_{10} - 5_{10} = 47_{10} \)[/tex].

### Part (ii) Binary subtraction using 2's complement

We need to subtract [tex]\(11010_2\)[/tex] from [tex]\(101011_2\)[/tex].

1. Step 1: Convert both numbers to the same bit-width if necessary.
- [tex]\(101011_2\)[/tex] is already 6 bits.
- [tex]\(11010_2\)[/tex] is 5 bits, so we pad it to 6 bits: [tex]\(011010_2\)[/tex].

2. Step 2: Find the 2's complement of the second number (011010).
- Find the 1's complement by flipping the bits: [tex]\(011010_2 \rightarrow 100101_2\)[/tex].
- Add 1 to the 1's complement: [tex]\(100101_2 + 1 = 100110_2\)[/tex].
- Thus, the 2's complement of [tex]\(011010_2\)[/tex] is [tex]\(100110_2\)[/tex].

3. Step 3: Add the original number to the 2's complement of the second number.
- [tex]\(101011_2\)[/tex] (original number)
- [tex]\(+ 100110_2\)[/tex] (2's complement of 011010)
- [tex]\(\hline\)[/tex]
- [tex]\(101011_2\)[/tex]
- [tex]\(+100110_2\)[/tex]
- [tex]\(\hline\)[/tex]
- [tex]\(1010001_2\)[/tex] (with carry)

4. Step 4: Discard any carry beyond the original bit-width.
- We initially used 6 bits.
- So, the resultant binary is [tex]\(010001_2\)[/tex], discarding the leftmost bit.

Hence, the result is [tex]\( 101011_2 - 11010_2 = 010001_2 \)[/tex].

Summary:
- Part (i): [tex]\( 52_{10} - 5_{10} = 47_{10} \)[/tex].
- Part (ii): [tex]\( 101011_2 - 11010_2 = 010001_2 \)[/tex].