Something like bigint / GMP?

  • Thread starter =?ISO-8859-2?Q?Rafa=B3?= Maj Raf256
  • Start date
?

=?ISO-8859-2?Q?Rafa=B3?= Maj Raf256

Hi, is there some small project that proviedes bigint, best as a C++ class,
or just as set of struct/functions (C-style)?

Something like GMP and it's bigint, but I want to have it just in one small
source file as small as needed, not to have entire advanced GMP library.
 
T

Thomas Matthews

Rafa³ Maj Raf256 said:
Hi, is there some small project that proviedes bigint, best as a C++ class,
or just as set of struct/functions (C-style)?

Something like GMP and it's bigint, but I want to have it just in one small
source file as small as needed, not to have entire advanced GMP library.

Do you want a C++ library or a C library?

Also, please don't post separately to many groups.
If you need to do that, put them all on the "To:"
field (or CC) when you post. That way, everybody
from all the newsgroups can see everybody else's
replies.

See my reply in
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 
A

Alex Vinokur

Rafa³ Maj Raf256 said:
Hi, is there some small project that proviedes bigint, best as a C++ class,
or just as set of struct/functions (C-style)?

Something like GMP and it's bigint, but I want to have it just in one small
source file as small as needed, not to have entire advanced GMP library.
[snip]

Look at C++ BigInt class
https://sourceforge.net/projects/cpp-bigint/
 
B

Basil

Rafa? Maj Raf256 said:
Hi, is there some small project that proviedes bigint, best as a C++ class,
or just as set of struct/functions (C-style)?

Something like GMP and it's bigint, but I want to have it just in one small
source file as small as needed, not to have entire advanced GMP library.

Hello.

Multiprecision unsigned number template library (MUNTL).

http://sourceforge.net/projects/muntl/

This is C++ template library for unsigned big integer. This library
very small (only 25Kb one header). This library very fast because it
do not use any heap call (like new, malloc etc.). All buffers is
static compile-time allocate. This library do not use GMP.

Sincerely yours
Basil
 
A

Alex Vinokur

Rafa³ Maj Raf256 said:
Thanx, it looks good, do You know perhaps what is the limit - can I use
1e32000 integers also?
[snip]


There is no logical limit.
Actual limit depends on specific machine resources.

Here is some test performed on Windows 2000.

/ ====== Test ======
int main ()
{
RossiBigInt result ("12", DEC_DIGIT);

for (int i = 0; ; i++)
{
ostringstream oss;
result = result * result * result * result * result;
oss << result;
cout << "The results contains " << oss.str().size() << " digits" << endl;
if (oss.str().size() > 32000) break;
}
return 0;
}
// ==================



// ====== Run ======

$ bigint.exe

The results contains 6 digits
The results contains 27 digits
The results contains 135 digits
The results contains 675 digits
The results contains 3373 digits
The results contains 16863 digits
The results contains 84312 digits

// =================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top