hello guys, i would like to ask again about this:

i am trying to divide two large-digit numbers (up to say 100 digits) using C. I thought of one approach but trying to code it, it seems so complicated... can anyone help me give an algorithm or a code to my program.... thanks...

Re: large number division 80 80

>but trying to code it, it seems so complicated
That's because it is complicated. Sorry.

Re: large number division 80 80

C'mon, Narue! :D

Ok, here's the deal: code add, subtract, and multiply. Come back when ready. ;)

Re: large number division 80 80

These are simple. Now code multiply to work in O(n log n) time instead of O(n*n) time. Come back when ready ;-)

Re: large number division 80 80

i have already coded the addition, subtraction and multiplication... i just would like to get some ideas from you guys with regards with division... because what i am thinking is very complicated and i might not be able to do it...thanks

Re: large number division 80 80

i have already coded the addition, subtraction and multiplication... i just would like to get some ideas from you guys with regards with division... because what i am thinking is very complicated and i might not be able to do it...thanks

Ok, well, see it....multiply=successive additions; divide=successive subtractions. This should be a breeze for you, having you've already coded the other three operations. ;)

Just note, division can give you real numbers. But the same algorithm can be extended if your structures have space for decimal places.

Re: large number division 80 80

Zeek, in the real world people don't use such numbers. For convenience in different sciences units are defined to mean something when the basic unit is on power (-3), (-6), (-9) and so on (as well as their positive corresponding values). Since you have put time and effort in this code it will probably be hard to leave it unfinished or if you don't want to - code it, but the problem remains - such thing is unnecessary. My advice is to redirect your efforts in C to something else. C is a very powerful and flexible low-level language and I'm sure you'll find something that suits you. I hope my advice is not discouraging!

Re: large number division 80 80

freemind, ever heard of RSA public key cryptography?

Re: large number division 80 80

Rashakil Fol, you know what I mean.

Re: large number division 80 80

I really don't. I use large integers frequently enough.

Re: large number division 80 80

i would first try to code the idea that i have and if its ok with you guys if i had problem with the code can i ask you again?... thanks for the replies...

Re: large number division 80 80

I did something along this line with large factorials and stored the results in character arrays. It is written in C++ but does not use any C++ specific features. So it is "almost C" ...
http://www.daniweb.com/code/showsnippet.php?codeid=233

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.