X = 00110 and Y = 10011 are two binary numbers represented in 2s compl...
To find the sum of X and Y represented in 2's complement format, we need to follow these steps:
1. Convert the binary representation of X and Y to their decimal equivalent:
- X = 00110 = 2^1 + 2^2 = 6
- Y = 10011 = -2^0 + 2^1 + 2^4 = -1 + 2 + 16 = 17
2. Add the decimal values of X and Y:
- 6 + 17 = 23
3. Convert the decimal sum back to binary representation:
- If the sum is positive (greater than or equal to 0), convert it to binary normally:
- 23 = 2^4 + 2^3 + 2^2 + 2^1 + 2^0 = 16 + 8 + 4 + 2 + 1 = 10111
- If the sum is negative (less than 0), convert the absolute value to binary and take the 2's complement:
- Absolute value of -23 = 23 = 10111
- Take the 2's complement by inverting all the bits and adding 1:
- Inverting: 10111 -> 01000
- Adding 1: 01000 + 1 = 01001
4. If the binary representation of the sum has more bits than the desired number of bits, truncate the most significant bits until the desired number of bits is reached. In this case, the desired number of bits is 5, so we can keep only the last 5 bits.
Therefore, the sum of X and Y represented in 2's complement format using 5 bits is 11001.
X = 00110 and Y = 10011 are two binary numbers represented in 2s compl...
X = 00110
since, the MSB = 0
∴ it is a positive number.
Decimal equivalent: 0 + 1 x 22 + 1 x 21 + 0 x 20 = + 6
Y = 10011
since, the MSB = 1
∴ it is a negative number,
We need to take the 2's complement of Y, that is.
1's complement (Y) + 1
01100 + 1
⇒ 01101
Decimal equivalent → 0 + 1 × 23 + 1 × 22 + 0 + 1 x 20 → -13
The sum of X and Y is
+6 - 13 = - 7
The 2's complement of - 7
→ 1's complement of 7 + 1
→ 1's complement of 00111 + 1
→ 11000 + 1 → 11001