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

Bitwise division

dkashyap01dkashyap01 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 ...

Comments

  • sgauravvsgauravv 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]""


Sign In or Register to comment.