How do I use bignum libraries

Announcements, comments, ideas, feedback, and "How do I... ?" questions
Post Reply
prasoon2211
Posts: 3
Joined: Wed Jul 06, 2011 12:30 pm

How do I use bignum libraries

Post by prasoon2211 »

To do problem 16, I had to learn python!
I am a still a novice and I program using C. But, with all the speed comes a bit of a limitation with C as well. The longest integer is unsigned long long int type and as I have learned, that is usually not good enough for project euler problems.

I know that you can use arrays to get around that problem. But, I also read on a blog about bignum libraries that can solve this problem. So, I went ahead and downloaded a couple: GMP, miracl and ttcalc...that was it. I have no idea how to actually use these.
The IDE I use is Dev-c++ on windows 7 64 bit version.

I could just continue using python...but it's slow. For instance, I just did problem 14...first with python, then, with the exact same algorithm in C. The python code ran for about 20 times as much as the C program did. Also, I'm more comfortable with C.

So, if someone could just explain how to use these bignum libs, that's be really great.
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: How do I use bignum libraries

Post by hk »

It seems that you have been crossposting in several threads.
I answered you in the other thread.
Image
War ruins the life and health of untold numbers of innocent children.
prasoon2211
Posts: 3
Joined: Wed Jul 06, 2011 12:30 pm

Re: How do I use bignum libraries

Post by prasoon2211 »

First of all, you have NOT answered my question (even in the other thread). You have merely commented on it.

Second of all, I did not cross-post in 'several' threads. Only two. Look up for what several means. Also, I did that because this was the first time I happened to use the PE forums and I didn't know that people can give 'answers' that quick.
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: How do I use bignum libraries

Post by hk »

Oh, I'm awfullyy sorry. I will never do that again. How stupid of me.
Nevertheless, you were crossposting weren't you?
When entering somewhere new, it might be wise to refrain from that, to see what happens first.
Image
War ruins the life and health of untold numbers of innocent children.
User avatar
Lord_Farin
Posts: 239
Joined: Wed Jul 01, 2009 10:43 am
Location: Netherlands

Re: How do I use bignum libraries

Post by Lord_Farin »

hk wrote:Oh, I'm awfullyy sorry. I will never do that again. How stupid of me.
It is not really stupid. It is comparable to someone asking how to make $5000 in 4 days because he has to make a tax payment by then, and you tell him how to request extension of the payment deadline. There's nothing wrong with solving (or, trying to solve) the problem by solving something further up the chain, at least not in my opinion.
Image
Hibernatus34
Posts: 31
Joined: Mon May 16, 2011 7:03 am

Re: How do I use bignum libraries

Post by Hibernatus34 »

prasoon2211 wrote:First of all, you have NOT answered my question (even in the other thread). You have merely commented on it.

Second of all, I did not cross-post in 'several' threads. Only two. Look up for what several means. Also, I did that because this was the first time I happened to use the PE forums and I didn't know that people can give 'answers' that quick.
Unless you're a C fanatic, i recommend using C++ for readability (objects and operator overloading make it look like true scalar types).
As an example, here is an easy to use C++ class (but slow and not as powerful as GMP) : http://sourceforge.net/projects/cpp-bigint/
I also recommend solving these problems the way they were intended to, because it takes less time than learning how to install and use GMP, and it's more fun.

Now, if what you really want is installing and using these libs, maybe you could ask that on a forum that is dedicated to C programming !
Image Joined PE in May 2011
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: How do I use bignum libraries

Post by hk »

Lord_Farin wrote:
hk wrote:Oh, I'm awfullyy sorry. I will never do that again. How stupid of me.
It is not really stupid. It is comparable to someone asking how to make $5000 in 4 days because he has to make a tax payment by then, and you tell him how to request extension of the payment deadline. There's nothing wrong with solving (or, trying to solve) the problem by solving something further up the chain, at least not in my opinion.
I'm allways happy to apologize. Particularly to people that are a little bit touchy. :)
Image
War ruins the life and health of untold numbers of innocent children.
Post Reply