• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need a fast free big number library for c++

Cogman

Lifer
So, I'm doing some number crunching (3x+1 if you must know). Since I will be dealing with large numbers, I need to use a library that supports them. Unfortunately, the NTL is out. It is not thread safe (the program is multithreaded, and needs to stay that way).

Any other suggestions for a free large number crunching library that is thread safe? It needs to support mod, divide, and addition, it would be nice if it where fairly quick as well.

As a side note, It was interesting how I discovered that the NTL isn't thread safe. All the numbers I am checking are odd, but just for my sanity, I decided to check that it was working ever 1000001 numbers. I started noticing that some of those numbers where even.... Last I checked an odd + an even doesn't equal an even 🙂.
 
Originally posted by: net
http://en.wikipedia.org/wiki/Limits.h

ULLONG_MAX

ULLONG_MAX isn't a data type, it is a number to give me what my current C++ compilers unsigned long long size is. And unfortunately it is too small. (I'm working with BIG numbers.)

I did find a replacement however, GMP should do nicely. It is said to be faster then the NTL and thread safe 🙂.
 
The fastest code for this kind of thing (prime searching?) might be GWNums, George Woltman's library for GIMPS. I've never successfully compiled anything with it, but you can find the source code link at the bottom of that page.
 
Back
Top