![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programming Guru
![]() |
Managing Excessively Large Numbers
By excessively large numbers, I'm not talking about "long long ints" or anything of that sort. I'm talking about a number, that could be up to 1000, 10 000, or even 1 000 000 digits? I assume this would require a unique dynamic storage and representation method.
Common mathematical operations need to be computable on this number (sqrt, divide, mod, exponent, add, subtract), and the data should only be limited by the program's allocated memory. Could anyone give me any starting points? Perhaps code from programs that have already done this before, something to get me started? I'm sure I could work something out from scratch, but I'd like to know if there are building blocks to give me a helping hand already. |
|
|
|
|
|
#2 |
|
Expert Programmer
|
Just out of curiosity, what level of accuracy are you looking for?
|
|
|
|
|
|
#3 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3
![]() |
I'm assuming you're looking for some sort of bignum library... http://www.swox.com/gmp/ might be worth looking at
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
|
|
#4 |
|
Programming Guru
![]() |
@titaniumdecoy: Perfect accuracy.
@Jimbo: Oh my god! This looks perfect! I'll give it a shot tomorrow. If anyone else knows of any other alternatives, please suggest them as well! Thanks. |
|
|
|
|
|
#5 |
|
Programming Guru
![]() |
I'm trying to compile it with Windows and Dev-C++ (for C) right now.
I found this: http://www.swox.com/list-archives/gm...er/001397.html I downloaded GMP, msvc, borland and mingw. But I'm a failure, I have no clue what to do with all of this. Would someone be kind and give me some instructions please? |
|
|
|
|
|
#6 |
|
Programming Guru
![]() |
I can't seem to get it working... I've tried the following...
Download : GMP, MinGW and Msys. 1 ) Put "c:/Dev-CPP" in the PATH variable. 2 ) Install MinGW 3 ) Install Msys 4 ) Unzip GMP 5 ) Run Msys 6 ) cd "location of GMP" ./configure --prefix="c:/dev-cpp" make make install Then when I execute the code... #include <gmp.h>
int main() {
mpz_t integ;
mpz_init (integ);
}[Linker error] undefined reference to `__gmpz_init' Last edited by Sane; Oct 22nd, 2006 at 6:08 PM. |
|
|
|
|
|
#7 |
|
Programmer
Join Date: Feb 2006
Posts: 36
Rep Power: 0
![]() |
linker error means you didn't link the library with your object files...
If you are in DevCpp there is an option to add library to linker (Project Properties I believe)... Or add it manually in your Makefile or command line... something like: gcc -o main.exe main.o -L"lib path" -lgmp |
|
|
|
|
|
#8 |
|
Programming Guru
![]() |
But the linking error isn't for #include <gmp.h>... Note the error message? It's with one of the functions.
Or does that not make a difference? I still might need to add the library to the linker? Edit : When I try executing the command... gcc -o is_prime2.exe is_prime.c -L"c:/dev-cpp/include/gmp.h" -lgmp gcc -o is_prime2.exe is_prime.c -L"c:/dev-cpp/include" -lgmp gcc -c is_prime2.exe is_prime.c -L"c:/dev-cpp/include/gmp.h" -lgmp gcc -c is_prime2.exe is_prime.c -L"c:/dev-cpp/include" -lgmp Last edited by Sane; Oct 22nd, 2006 at 7:43 PM. |
|
|
|
|
|
#9 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
maybe separate the digits of power ten, then recombine them?
whoah, i'm drunk...and a total n00b. that crap just sprang into my head...either genius or retardation. probably the latter.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#10 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 852
Rep Power: 4
![]() |
The -L option controls the location that the linker looks for libraries, it should almost never have an include path in it.
Your previous post said you "executed the code" and got a linker error, but now you say you are getting compiler errors. How did you compile it the first time? You need to add the -L<whatever> and -lgmp to the compiler command line, not replace whatever was already there. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Median/Mode in arrays? {Need help} | Java|Tera | Java | 27 | Nov 29th, 2005 10:50 AM |
| Sorting without a large array | sim_maroon | C | 12 | Nov 21st, 2005 8:45 PM |
| Reading in multiple numbers | wingz198 | C++ | 2 | Oct 14th, 2005 1:45 PM |
| Prime Numbers | Konnor | C++ | 6 | Sep 12th, 2005 6:46 PM |
| Assignment of numbers to variables without asking | Haz | C# | 26 | May 23rd, 2005 10:30 AM |