Thursday, 15 February 2024

addition and subtraction of unsigned and signed numbers

Advertisemtnt

The direct method of subtraction taught in elementary schools uses the borrow concept. In this method we borrow a 1 from a higher significant position when the minuend digit is smaller than the corresponding subtrahend digit. This seems to be easiest when people perform subtraction with paper and pencil. When subtraction is implemented with digital hardware, this method is found to be less efficient than the method that uses complements.

The subtraction of two n-digit unsigned numbers M - N (N * 0) in base r can be done as follows:

1. Add the minuend M to the r's complement of the subtrahend N. This performs M + (r' - N) = M - N + r'.

2. If M "" N, the sum will produce an end carry r' which is discarded, and what is left is the result M - N.

3. If M < N, the sum does not produce an end carry and is equal to r' - (N - M), which is the r's complement of (N - M). To obtain the answer in a familiar form, take the r' s complement of the sum and place a negative sign in front.

Consider, for example, the subtraction 72532 - 13250 = 59282. The lO's complement of 13250 is 86750. Therefore:

M = 72532

lO's complement of N = +86750

Sum = 159282

Discard end carry 10' = -100000

Answer = 59282

Now consider an example with M < N. The subtraction 13250 - 72532 produces negative 59282. Using the procedure with complements, we have

M = 13250

lO's complement of N = +27468

Sum = 40718

There is no end carry.

Answer is negative 59282 = 10's complement of 40718

Since we are dealing with unsigned numbers, there is really no way to get an unsigned result for the second example. When working with paper and pencil, we recognize that the answer must be changed to a signed negative number. When subtracting with complements, the negative answer is recognized by the absence of the end carry and the complemented result.

Subtraction with complements is done with binary numbers in a similar manner using the same procedure outlined above. Using the two binary numbers X = 1010100 and Y = 1000011, we perform the subtraction X - Y and Y - X using 2's complemenfs:

X= 1010100

2' s complement of Y = +0111101

Sum = 10010001

Discard end carry 27 = - 10000000

Answer: X - Y = 0010001

y = 1000011

2's complement of X = +0101 100

Sum = 1101111

There is no end carry

Answer is negative 0010001 = 2's complement of 1101111

Advertisemtnt

0comments:

Post a Comment

Note: only a member of this blog may post a comment.

Advertisement

Follow US

Join 12,000+ People Following

Notifications

More

Results

More

Java Tutorial

More

Digital Logic design Tutorial

More

syllabus

More

ANU Materials

More

Advertisement

Top