You are not logged in.
Pages: 1
Hi all,
I'm writing a program that deals with _very_ large numbers. Specifically, I want to represent at least 25! (which is bigger than 10^25). I have already tried out the unsigned long long int, but it is not big enough.
Thanks for any help!
- MrAllan
Last edited by MrAllan (2009-12-29 13:36:08)
Offline
Hi MrAllan,
I've needed this once (for Project Euler) and I used http://gmplib.org (pacman -S gmp) It was reasonably easy to use and worked quite fast. (I think Haskell uses it too for its Integer implementation.)
Offline
I've needed this once (for Project Euler) and I used http://gmplib.org (pacman -S gmp)
ditto. I used it to calculate pi, and its pretty simple in C++
Offline
Hi MrAllan,
I've needed this once (for Project Euler) and I used http://gmplib.org (pacman -S gmp) It was reasonably easy to use and worked quite fast. (I think Haskell uses it too for its Integer implementation.)
Thanks for the answer! I tried out GMP, but I get an error:
"___gmpz_init", referenced from: _main in main.o
Symbol(s) not found
Collect2:ld returned 1 exit status
Here's my code:
#include <stdio.h>
#include </usr/include/gmp.h>
int main (int argc, const char * argv[]) {
mpz_t integ;
mpz_init(integ);
return 0;
}
What am I doing wrong?
Offline
What am I doing wrong?
You probably aren't linking the library during the compilation.
You have to pass -lgmp to gcc
[andrea@consistemi gmptest]$ gcc test.c
/tmp/cc0ucLbR.o: In function `main':
test.c:(.text+0x11): undefined reference to `__gmpz_init'
collect2: ld returned 1 exit status
[andrea@consistemi gmptest]$ gcc -lgmp test.c
[andrea@consistemi gmptest]$ ./a.out
Also the include is not correct
#include </usr/include/gmp.h> // should be #include <gmp.h>
Offline
Also the include is not correct
#include </usr/include/gmp.h> // should be #include <gmp.h>
I actually had just "#include <gmp.h>" before, but then it would muck about how it couldn't find "no such file or directory".
Whatever, now it works, so thanks a lot!
Offline
Pages: 1