Big Numbers

Started by
26 comments, last by jperalta 19 years, 6 months ago
Hello. I have done some work on the Erdos-Strauss Conjecture, and I think I have found a new way how to calculate results. Currently, a method has been developed that has calculated a solution for every number up to 10^14. I would like to match that number with my method. The problem is, I can't seem to find any way how to support numbers that large. Since the method I have involves multiplication, I may need to use numbers as large as 10^20 in my calculations. I also need to use an effecient language for this sort of thing, because as it is it will probably take days to run the program. Can anyone suggest a language to use, and a way to use numbers so large?
Advertisement
GNU Multiprecision Library
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
I believe LISP supports ints of any size. And if you want to use c or c++ you can use
http://www.swox.com/gmp/

I'm assuming you only need ints (rationals shouldn't be to hard to add).

I've never used gmp, and my LISP is limited. So you may want to look for more experienced suggestions.

Just in case you use Java you can use the BigInteger class. I actually don't know the limits for the numbers used, but i think it'll be ok. Once i experimentated and calcultated the factorial of 1000 (which is pretty big). And it was decently fast too.
Under ANSI C++ you should have a variable keyword called the long long which according to specification should be 64 bits, i.e. ranged from 0 to 18446744073709551615.
william bubel
Quote:Original post by Inmate2993
Under ANSI C++ you should have a variable keyword called the long long which according to specification should be 64 bits, i.e. ranged from 0 to 18446744073709551615.


That's not actually enough for 10^20, log-base 10 of 2^64 is only 19, which means you can only get up to 10^19 out of 2^64 bits.

I, personally, despite how much I despise LISP and its derivitives, have had great success using Scheme for large integer calculations. I've also used a BigInteger class in C# that supports memory-sized integers that works pretty nicely and can link in with any .NET language.
Still, 19 is close to 20, and with a little tweeking of the algorithm it might just be enough. It would certainly make the program run faster, especially on 64 bit hardware.
Quote:Original post by Wutalife37
Hello. I have done some work on the Erdos-Strauss Conjecture, and I think I have found a new way how to calculate results. Currently, a method has been developed that has calculated a solution for every number up to 10^14. I would like to match that number with my method.


Hey, can you please bring this on topic? How is it related to game development?
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Quote:Hey, can you please bring this on topic? How is it related to game development?


Isn't this the Math and Physics forum?
Sorry, I didn't know it needed to be related to game development for this forum. If necessary, I have no problem with it being moved to the general programming section.

This topic is closed to new replies.

Advertisement