0
\$\begingroup\$

Hi i need help in understanding the binary division restoring method From -2, we stored the value to 5 by adding the divisor which is 7 After adding 7 to get 5, why does it automatically jump to 10? So from 5-7 = -2, restore -2+7=5 => 10-7=3

Where does this 10 from, and can anyone explain why this form of divison works?

Source: https://userpages.umbc.edu/~squire/cs411_l10.html

enter image description here

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

It's similar to the normal long division algorithm in decimal, with one modification to combine a check for less-than / greater-than with the subsequent subtraction. You can just do the subtraction regardless, and if the value is negative, then you "messed up" and shouldn't have subtracted it. Just add it back to undo the mistake, then continue on to the next digit.

For example, in normal decimal long division, if you were dividing 120 by 8, the first thing you would check is whether 8 > 1. Since it is, you keep the value '8' as the first digit of your partial value and don't do any subtraction. Next you would drop down the 2 and check if 8 > 12. It's not, so determine how many times it goes into 12, which is 1. (In binary, this answer is always 1). And so on...

Using the same example with the "restoring method", you first do 1 - 8. The answer is -7, so the result will have a 0 in that bit/digit, and you add back +8 to get back to a partial value of 1. Then drop down the 2, do 12 - 8, and get a value of +4. Since it's positive, that digit of the result is a 1.

It's not how I would normally think of doing it, but I suppose it works. The example for decimal won't always work perfectly since it's missing the test for quotient digits 2 through 9.

Also, you asked where the 10 came from. It's just the decimal value of 01010, the first 5 bits of the dividend.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.