Sign in to follow this  
jeff8j

Bitwise division

Recommended Posts

jeff8j    787
I have been trying to do this for a hobby project of mine for weeks now and for the life of me i cannot figure it out. Im am trying to implement division for my 32 bit integers but the processor that im using does not have division (long story) and I need division im at a stand still and cannot figure any of this out its driving me insane. I need to do simple integer division using only bit shifts can someone help me out with this. Thank you

oh and im using c++ but any pseudo code or code snipnet would help

Share this post


Link to post
Share on other sites
karwosts    840
When you mean only bit shifts, does that mean you can't use addition/subtraction?

A quick search brings up many many articles with division algorithms, or is yours a special case somehow?

http://www.bearcave.com/software/divide.htm

Share this post


Link to post
Share on other sites
jeff8j    787
wow that was fast! I have addition and substraction and i implemented multiplication using bit shifts. I had that page up at one point in time but lost it and havent found an equivalent since (i think i have just been starring at all this way to much lol). Thank you for the link im going to try to implement that into my code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this