# Help needed with VERY large numbers.

• 01-15-2004
jwarner
Help needed with VERY large numbers.
I am trying to write a program that does integer math on extremely large numbers.

Basically, I'm going to be multiplying two numbers in the range of 250 (decimal) digits together, and comparing the results to a much larger number (say 500 decimal digits). Based on the results of the comparison, one of the two initial numbers will be modified.

My question is, how would I set these extremely long numbers as variables? I know that a 1560bit number will not fit into a "long long". Anyone know of any libraries or anything that might help me with this?

Thanks!
Jeff
• 01-15-2004
Salem
• 01-15-2004
DougDbug
This was discussed recently...
So, search the board. (I didn't follow the discussion, so I don't know the details.)

There are libraries. You'd have to search the net.

You could write your own, if you want to do it as a learning exercise... imagine that you are using one of those mechanical counters to count the number of people entering a stadium. If the counter only goes up to 999, what do you do? Get two of them and use the second one to count how many times the first one rolls-over. (Your mathmatical operations require a bit more thinking.)

[EDIT]
I see Salem beat me to it... with a better, more specific answer! ... I was afraid you were going to get a rude "Search the freekin' board" answer. :)

BTW - I would not attempt to write my own BigInt library, unless I really wanted to. It could turn-out to be a bigger project, than the program that utilizes the library! It's almost always better to use a pre-existing library. (Of course, sometimes cost is a consideration too.)
• 01-17-2004
jwarner
hrmm...

Does anyone know of any tutorials for using GMP? I am by far not a programmer, and I'm just trying to do some simple multiplication and compare the results. The GMP manual is great at telling how it does what it does, but for someone who struggles with basic "printf" commands, and needs to refer to a programming book to know how to do a carriage return line feed, they do not seem to offer much in the way of examples on how to use the library.

Any help would be, well, helpful. :)

Thank you for your time, and I apologize if this has already been covered on the forum, I tried searching the board for information on this, as well as Google.com, and I found a lot about GMP, but it was all too advanced for me.

Thanks again!

jwarner
• 01-18-2004
Zach L.
If you're that new to programming, I would suggest postponing this project until you are a good deal more familiar with the language, and programming in general. Perhaps make a smaller version of your program (with numbers computable by primitive types) now, and then move on later once you are familiar with OOP and using libraries, etc.