# unsigned 6-bit integer division ?

i am trying to divide 50 by 23 . These are unsigned 6-bit integers.

50 = 00110010
23 = 00010111

since numbers are 6 bits there are 7 steps.

after the 6th step R=R-D since result is not negative remainder becomes 000100 and
quotient = 0001 , divisor - 101110 (before shifted to right). I don't know what to do next
I'm not sure whether i am doing it right way. Can someone explain this?

Thanks
###### Who is Participating?

Commented:
The trick is that you need to normalize the numbers properly before starting the division. Starting with the numbers naively results in garbage -- see below.
Compare the example in the text book on page 186: the 4 bit divisor is scaled by shifting it left 4 bits initially.
``````Wrong:
=====
At START:  R = 00110010  D = 00010111  Q = 00000000
After 1:   R = 00011011  D = 00010111  Q = 00000000
After 2a:  R = 00011011  D = 00010111  Q = 00000001
After 3:   R = 00011011  D = 00001011  Q = 00000001
After 1:   R = 00010000  D = 00001011  Q = 00000001
After 2a:  R = 00010000  D = 00001011  Q = 00000011
After 3:   R = 00010000  D = 00000101  Q = 00000011
After 1:   R = 00001011  D = 00000101  Q = 00000011
After 2a:  R = 00001011  D = 00000101  Q = 00000111
After 3:   R = 00001011  D = 00000010  Q = 00000111
After 1:   R = 00001001  D = 00000010  Q = 00000111
After 2a:  R = 00001001  D = 00000010  Q = 00001111
After 3:   R = 00001001  D = 00000001  Q = 00001111
After 1:   R = 00001000  D = 00000001  Q = 00001111
After 2a:  R = 00001000  D = 00000001  Q = 00011111
After 3:   R = 00001000  D = 00000000  Q = 00011111
After 1:   R = 00001000  D = 00000000  Q = 00011111
After 2a:  R = 00001000  D = 00000000  Q = 00111111
After 3:   R = 00001000  D = 00000000  Q = 00111111
After 1:   R = 00001000  D = 00000000  Q = 00111111
After 2a:  R = 00001000  D = 00000000  Q = 01111111
After 3:   R = 00001000  D = 00000000  Q = 01111111
After 1:   R = 00001000  D = 00000000  Q = 01111111
After 2a:  R = 00001000  D = 00000000  Q = 11111111
After 3:   R = 00001000  D = 00000000  Q = 11111111

Hence the result of the program is:
"50 / 23 is  -1 remainder 8" -- not very promising

RIGHT:
=====
At START:  R = 000000 110010  D = 010111 000000  Q = 000000 000000
first round:
After 1:   R < 0
After 2b:  R = 110010  D = 010111 000000  Q = 000000
After 3:   R = 110010  D = 001011 100000  Q = 000000
second round:
After 1:   R < 0
...
After 3:   R = 110010  D = 000000 101110  Q = 000000
sixth round:
After 1:   R = 000100  D = 000000 101110  Q = 000000
After 2a:  R = 000100  D = 101110  Q = 000001
After 3:   R = 000100  D = 010111  Q = 000001
seventh round:
After 1:   R < 0
After 2b:  R = 000100  D = 010111  Q = 000010
After 3:   R = 000100  D = 001011  Q = 000010

END

Now the result is "50 / 23 is 2 remainder 4" as expected
``````
0

Commented:
How did you get to that step?
0

Commented:
What algorithm do you use?
0

Author Commented:
0

Author Commented:
Thank you. I have another question. how can i divide 25 by 44. since the quotient will never be 1. how can i calculate it using same algorithm?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.