186k views
5 votes
Add the two binary numbers: (01101110) and (01011001) and write your answer in Binary.Assume that we have an 8bit machine and used the 2’s complement

2 Answers

1 vote

Answer:

1 1 0 0 0 1 1 1₂ ---------------- An overflow occurred.

Step-by-step explanation:

Problem to solve is:

0 1 1 0 1 1 1 0 + 0 1 0 1 1 0 0 1

For a 2's complement representation of a binary number, the leftmost bit in the number determines the sign of the number. If the leftmost bit is 0, then the number is positive. If the leftmost bit is 1, then the number is negative.

Following from the foregoing, the first number (0 1 1 0 1 1 1 0) is positive because in its 8-bit representation, its leftmost bit is 0.

Also, the second number (0 1 0 1 1 0 0 1) is positive because in its 8-bit representation, its leftmost bit is 0.

Therefore the addition of the two numbers follow the normal procedure of adding binary numbers together. i.e

0 1 1 0 1 1 1 0₂

0 1 0 1 1 0 0 1₂

1 1 0 0 0 1 1 1₂ ----------------An overflow has occurred.

The result of the operation gives 1 1 0 0 0 1 1 1₂ showing that the number is a negative number as its leftmost bit is 1. This shows also, that an overflow has occurred. The sum of two positive numbers is not supposed to give a negative result.

One way to deal with this is to increase the number of bits of the machine from 8-bit to say 16-bit as the 8-bit representation cannot accommodate the result got from this addition.

User Rpg
by
5.4k points
5 votes

Answer:

by adding these two numbers the answer is 1 1 0 0 0 1 1 1. Adding two positive numbers doesn't require 2's complement

Step-by-step explanation:

0 1 1 0 1 1 1 0

+ 0 1 0 1 1 0 0 1

1 1 0 0 0 1 1 1

But we use 2's complement only when negative numbers are involved. As the question is not clear and where is the negative number has not been mentioned in the question, I shall explain below what might be the cases:

1. If we have to calculate 01101110-01011001 by 2's complement method

2's complement of 01011001 = 10100110+1 = 10100111

01101110 - 01011001 = 01101110 + 10100111 = 1 0001 0101‬

2. If given numbers are already 2's complement of some numbers and we have to add original numbers

01101110 is 2's complement of 10010010

01011001 is 2's complement of 10100111

then 10010010+10100111 = 10011 1001‬ (as our machine is 8 bit so we shall ignore 9th bit)

= 00111001

and notice that 00111001 is 2's complement of 11000111 that is some of two numbers given in the question (-11000111 = 00111000+1 = 00111001)

conclusion: 2'complement(x) + 2's complement(y) = 2's complement(x+y)

NOTE: If x is 2's complement of y then y is 2's complement of x

User Stalfos
by
5.4k points