0

Hi and I am making a maths library which will accept infinit digits but what is the best formula a computer can understand for devision. The only one I have come across so far is long devision but is there anything better? The following is the kinda formula I am thinking of doing...

input1=8
input2=3
amount=0
answer=0
while (amount<=(input1-input2)) {
amount = amount + input2
answer = answer + 1
}
remainder = input1-amount

//------ results
remainder
floor of answer
//------

Now that I have the floor(answer) and the remainder, how do I work out the 0.666666666 which ((1/input2)*remainder) will give. Of course I am making a division algorithm so I can't use division or multiplication to get the answer. I can only use addition and subtraction. I think long devision is a slow answer but is there anything faster. By faster I mean less use of addition and subtraction but only use of addition and subtraction. Any ideas explained clearly??

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by cwarn23
0

First the numbers you can accept is limited to the bytes of memory the
computer has. For an algorithm for division of large numbers, google
newton raphson method.

0

I have tried the Russian Peasant Algorithm and although it makes a great multiplication algorithm (which I needed) I still need however a division algorithm which is to some degree easy to understand. The basic requirements to this algorithm unlike before is that the algorithm can only contain addition, subtraction and multiplication (plus loops, greater than symbols and possibly a few other minor features) but one of the things it cannot contain is the >> or << operators. Can anyone provide such an algorithm and Newtons algorithm is terribly hard to translate as it uses devision to make the devision algorithm. Thanks...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.