Page 1 of 1

plz help me with these question and l don't have a clue to t

Posted: Thu Jun 26, 2008 12:39 pm
by kuul
write a program that weill divide two (2) N digit positve intergeres, where N may be arbitrarily large. your program should output the result of the divisioin and the remainde
sample input
enter a number 65656432310964579864321356898765432243578987876654
enter its divisor 94454

sample output
the quotient is 695115424555493466586584528963997631054047344
the remiander is 46478

Posted: Fri Jun 27, 2008 10:22 am
by Ralph
As Burger 2227 explained to you in your next post, we believe that homework is a very necessary part of one's path towards learning, so, "we don't do homework". However, all here want to help others. It is our firm intention to help if you make an honest effort and post some code, explaining what specific problem you are having. We will then provide guides and explanations to help you advance with your code. This is based on the assumption that you want to learn how to code. If you have no interest in coding, you should not waste your time, and should get out of that class as soon as possible!

Posted: Fri Jun 27, 2008 10:37 am
by Ralph
Oops, posted twice! Sorry. How does one delete such a second posting?

Posted: Fri Jun 27, 2008 12:08 pm
by kuul
thanks you all and l am more than willing to to accept any assistance you are going to me. thnk you once more

Deleting a post

Posted: Fri Jun 27, 2008 12:32 pm
by burger2227
To delete a recent post, just edit it and check the "Delete Post" box Ralph.

That will not work if it is a new thread post however! You can Delete posts only for a limited time too.

KUUL, INTEGERs (%) in QB can only be up to 32,767. LONG integers (&) can be be up to 2,147,483,647. Look up Integer division and MOD.

Ted

Maybe this might work

Posted: Mon Jun 30, 2008 1:19 am
by Kiyotewolf
Divide your large number by a large numeric, 1000000000000000000, so that the number can fit inside of a Long-Int declaration. What you have to do to do this, is manually enter the decimal into the string, using string commands, then use the VAL expression to convert the over sized number into a Double Precision variable. Once you have the answer, round back to the same number of decimal places, then remove the decimal.

I don't wanna try attempting to code it cause I am afraid of huge numbers like that.. O.O

Long division?

Posted: Tue Jul 01, 2008 7:48 am
by markm
Double precision arithmetic is only approximate, and no numeric data type I've ever heard of would take such long numbers without truncation. So to me, it sounds like the object of the assignment was to represent the very long numbers as strings or arrays of decimal digits and code the long division algorithm that you (should have) learned in elementary school. This will give exact results (including a remainder, or ending in a repeating decimal) for any number that will fit in memory. It is a tough problem.

Some hints: If the numbers come in as strings, convert to arrays of integers 0-9. For one digit D$, you get this value with ASC(D$)-ASC("0"). You also need a FOR loop and the MID$ function. You need three arrays; one is the dividend initially and then becomes the remainder, the second is the divisor, and the third is the result.

With pencil and paper, the toughest part of the algorithm is guessing the largest digit that, times the divisor, is less than or equal to the divisor or remainder. Instead of trying to code that, just subtract the divisor (suitably shifted left or right) until the remainder is less than the divisor; the number of times you subtracted is the result digit. This not only eliminates the guessing, but it also means you don't have to code multiplication as well.

Of course, if Kuul doesn't know how to subtract and divide with pencil and paper, he's got a problem...