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...

## All 11 Replies

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

C'mon, Narue! :D

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

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

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

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.

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!

freemind, ever heard of RSA public key cryptography?

Rashakil Fol, you know what I mean.

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

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...

Be a part of the DaniWeb community

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