Bitwise division - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Bitwise division

Posts: 1Member
How to divide a two number by using bitwise operator in C. The number can any number. ie: 3/5 or 9/7 ...

• Posts: 4Member
: How to divide a two number by using bitwise operator in C. The
: number can any number. ie: 3/5 or 9/7 ...
:
hi
i am sending u the algorithm in which we can divide the bits

[color=Red][size=2]Binary Division by Shift and Subtract
Basically the reverse of the mutliply by shift and add.

Set quotient to 0
Align leftmost digits in dividend and divisor
Repeat
If that portion of the dividend above the divisor is greater than or equal to the divisor
Then subtract divisor from that portion of the dividend and
Concatentate 1 to the right hand end of the quotient
Else concatentate 0 to the right hand end of the quotient
Shift the divisor one place right
Until dividend is less than the divisor
quotient is correct, dividend is remainder
STOP [/size][/color]

or just go for this link.....

""[color=Green]http://courses.cs.vt.edu/~cs1104/BuildingBlocks/divide.030.html[/color]""