Ask Your Question
0

How can binary division be performed for signed numbers using 2's complement?

asked 2023-05-13 08:33:48 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-05-13 08:57:02 +0000

lalupa gravatar image

To perform binary division for signed numbers using 2's complement, follow these steps:

  1. Convert both the dividend and divisor into their 2's complement representation. This involves inverting all the bits and then adding 1.

  2. Perform division as usual, ignoring the sign bit.

  3. Check the sign of the resulting quotient and remainder. If the signs of the dividend and divisor are different, the quotient and remainder must be negated.

  4. Convert the quotient and remainder back into their signed representation by inverting the bits and adding 1.

  5. Return the signed quotient and remainder.

For example, let's divide -9 by 3 using binary division with 2's complement:

-9 in 2's complement: 11110111 3 in 2's complement: 00000011

Divide as usual to get quotient 10 and remainder 1. Signs are different, so negate both quotient and remainder: Quotient becomes -10 in 2's complement: 11101110 Remainder becomes -1 in 2's complement: 11111111

Convert back to signed representation by inverting all bits and adding 1: Quotient is -6: 11111010 Remainder is -1: 11111111

Therefore, -9 divided by 3 is -6 with a remainder of -1.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-13 08:33:48 +0000

Seen: 7 times

Last updated: May 13 '23