This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

c code for division of 32bit/32bit no

i want to divide 32bit/32bit no i don't know the procedure so
pls send me the procedure who to divide

  • STOP, STOP, STOP

    This is getting ridiculous

    STAY IN THE THREADS

  • The answer is quite simple: No one will give you a single bit of code on this forum.

    If you completely ignore all other people, then all other people will ignore you. Go spam another forum - maybe you can find a fool to give you advice.

    The problem is of course that only a fool would listen to advice from a fool...

  • " want to divide 32bit/32bit no i don't know the procedure"

    If you really don't know the procedure for something as trivial as that, then it's not a forum that you need - it's a basic 'C' textbook.

    'C' has the four basic arithmetic operators built in - that's addition, subtraction, multiplication, and division.

    You don't need any "algorithm" - it's just a basic expression, a=b/c.

  • Which part of Don't keep starting new threads don't you understand

    PLEASE stop answering posts from this idiot, maybe he will go away

  • There are several algorithms for doing this. You could just look at how the library code does this.

    Do a web search for "32 bit divide algorithms ARM", or more general, divide algorithms.

    The main thing is to generate the inverse of a number, like 1 / D. Here's a sample algorithm:

    Q0 = estimated quotient (from a table)

    Then repeat this sequence until you get enough bits of precision

    Q1 = Q0(2 - (Q0 x D))
    Q2 = Q1(2 - (Q1 x D))
    Q3 = Q2(2 - (Q2 x D))
    Q4 = Q3(2 - (Q3 x D))

    Note this sequence is what would be done for fixed or floating point numbers. For integers, you'd have to scale the results to keep them within a 32 bit range.

    I can't remember the exact rate precision increase for each step, but 4 iterations are enough if you start with 8 bits of precision or more from a table.

    There are some clever tricks to optmize this by unfolding loops and scaling thing properly.

  • "Do a web search for '32 bit divide algorithms ARM'..."

    Why would he search for ARM algorithms when he's using C51?

    Why, in fact, search for anything at all when C51 supports 32-bit data types anyhow?!
    As would any ARM 'C' compiler!

    All this has already been said as nauseam in his many cross-posts - hence the preceding posts, PLEASE stop answering posts from this idiot, maybe he will go away - and it appears that he has gone away!