Welcome to the GNU MP web pages! Here you can find information about the GMP library, some important patches, and an outline of planned future developments. You can also find the manual and some useful diagrams here.

What is GMP?
GMP function classes
GMP documentation
Download the latest release of GMP
Improving GMP
Frequently asked questions
Status of the current release
Projects using GMP
Try GMP!
Future releases


What is GMP?

GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. There is no limit to the precision except the ones implied by the available memory in the machine GMP runs on. GMP has a rich set of functions, and the functions have a regular interface.

GMP is designed to be as fast as possible, both for small operands and for huge operands. The speed is achieved by using fullwords as the basic arithmetic type, by using fast algorithms, with carefully optimized assembly code for the most common inner loops for a lot of CPUs, and by a general emphasis on speed (instead of simplicity or elegance).

GMP is believed to be faster than any other similar library. The advantage for GMP increases with the operand sizes for certain operations, since GMP in many cases has asymptotically faster algorithms.

GMP is distributed under the GNU Library General Public License. For more information about the GNU project, please see the official GNU web site.

GMP function classes

There are five classes of functions in GMP.

GMP documentation (online and offline)

Complete documentation for GMP is available in the GMP Manual. It is also available for download in DVI format (42KB gzip'ed) and in PostScript format (114KB gzip'ed).

The speed of GMP varies a lot on different CPUs. See the GMP speed chart for details.

Download the latest release of GMP

Here you can download the complete sources for GMP:
ftp://ftp.sunet.se/pub/gnu/gmp-2.0.2.tar.gz (Sweden)
ftp://ftp.funet.fi/pub/gnu/prep/gmp-2.0.2.tar.gz (Finland)
ftp://ftp.informatik.rwth-aachen.de/pub/gnu/gmp-2.0.2.tar.gz (Germany)
ftp://utsun.s.u-tokyo.ac.jp/ftpsync/prep/gmp-2.0.2.tar.gz (Japan)
ftp://labrea.stanford.edu/pub/gnu/gmp-2.0.2.tar.gz (USA, Pacific)
ftp://ftp.gnu.org/pub/gnu/gmp-2.0.2.tar.gz (USA, East)

Improving GMP

Since GMP is free software, anybody can improve it and pass on the result, as permitted by the GNU Library General Public License. If you need an enhancement, but don't want to do the work yourself, you can pay somebody to do it for you. Try asking bug-gmp@gnu.org!

If you have written an improvement, please send it to bug-gmp@gnu.org so that it may be included in the next public release. If you plan on making an improvement, please first write to the same address, to make sure your effort is not duplicated.

Frequently asked questions

Q: Is there a C++ wrapper for GMP?

A: No, none as far as I know. Many people have started writing one, but nobody has ever sent me any useful code. "Useful" here means complete, efficient, and well-tested. (I intend to write a spec later and put it here.)

Q: When will the next release happen?

A: Hard to tell. I'd like to make it in mid 1999.

Q: I get a Segfault/Bus error in a program that uses GMP to calculate numbers with several hundred thousand digits. Why?

A: GMP allocates most temporaries on the stack, and some machines give user programs very little stack space by default. See setrlimit(2) for information on how to increase the stack allocation. You can also change it from the shell (using ulimit or limit depending on the shell). If you're not using Unix, then recompile the library using `make CFLAGS="-g -DUSE_STACK_ALLOC"'. (Yes, that is backwards..!)

Q: Are there known bugs in GMP?

A: See under "Status ..." a few lines below.

Q: I am working on Y2K certification here at Gull Enterprises. Can you tell me if GMP is year 2000 compliant?

A: GMP was designed for the sole purpose of solving this sort of problems. Just make sure to use the GMP supplied type mpz_t for all year data, and then sleep tight.

Q: What kind of answer is that?

A: Just kidding. But the Y2K question has been posed to the gmp mailing list several times!

Status of the current release

The current release is 2.0.2, released June 6, 1996. It was a good release, with no serious bugs in the integer functions, and with only a few serious bugs in the functions for rational numbers and floating-point numbers:

Some Linux distributions have a buggy ar program that omits many of the files from libgmp.a. As a result libgmp.a becomes useless. The best solution is to get a newer GNU release of binutils, version 2.6 or later. As a workaround, you could also apply this patch to the top-level directory of GMP 2.0.2, if you don't want to upgrade your Linux tools. The patch was written by Alexander Zimmermann.

Projects using GMP

There are several interesting projects that rely on GMP. Here are some of the ones I am aware of: There are also several projects using GMP to produce non-free software. It's too bad they chose not to share their work with the rest of us, and I won't add pointers to such projects, no matter how interesting! The EU sponsors lots of projects, several of them being based on GMP. But the EU requires that the result of projects they sponsor be non-free, which caused them to quickly be forgotten. (It is a shame for Europe that almost all cool free software is written in USA! Just think of GNU, X Windows, MIT Athena, Coda, Berkely Unix (FreeBSD, NetBSD), etc, etc. We should be grateful the EU never got any money into Linux, because then you would never have heard of it and it would just run on some obscure Transputer-based computer...!)

Try GMP!

Enter an integer expression in the field below. The expression may include +, -, *, /, %, ^ (exponentialization), and ! (factorial), the n-ary functions `gcd', `lcm', `and', `ior', `xor', `mul', `plus', the binary functions `minus', `div', `mod', `rem', and the unary function `popc' (population count). Most functions may also be used in infix form. All constants must be integers.

An example of a valid expression is:

1 + gcd(87324,78263148,7896) * (10^1989879887 mod 471!)

This is computed on a 200MHz Amd K6 running FreeBSD.

If you want to know how to do things such as this with GMP, take a look at the source code of the program used to compute these expressions.

Future releases

GMP 2.0.3 will be released in as soon as I can find the time to put it together. It will have fixes for all problems reported, and will work properly under Irix 6.

I hope to make a new major GMP release during 1999. I am looking for sponsors willing to support this work. Without sponsors, I do GMP in my spare time, and thus a release can be indefinitely delayed.

Here are the features that are scheduled for GMP 2.1:


Please send comments about this page to tege@swox.com.
Copyright (C) 1999 Torbjörn Granlund.
Valid HTML 3.2!