954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

large number division

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

zeek
Newbie Poster
9 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

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

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

C'mon, Narue! :D

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

Alvein
Junior Poster
104 posts since Jul 2005
Reputation Points: 12
Solved Threads: 4
 

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

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

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

zeek
Newbie Poster
9 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 
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.

Alvein
Junior Poster
104 posts since Jul 2005
Reputation Points: 12
Solved Threads: 4
 

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
Junior Poster in Training
62 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

freemind, ever heard of RSA public key cryptography?

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

Rashakil Fol, you know what I mean.

freemind
Junior Poster in Training
62 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

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

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

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

zeek
Newbie Poster
9 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

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

vegaseat
DaniWeb's Hypocrite
Moderator
5,987 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You