|
Welcome to the GMP web pages! Here you can find information about the GNU Multiple Precision Arithmetic Library, the fastest bignum library on the planet! |
|
|
|
IMPORTANT INFORMATION FOR ALL GMP USERS:
GMP is very often miscompiled! Please never use your newly compiled
libgmp.a or libgmp.so without first
running make check.
If it doesn't complete without errors, don't trust the library. Please try
another compiler release, or change optimization flags until it works. If you
don't have the skill to isolate the problem, please report it to us if it was a
GMP bug; else to the compiler vendor. (The compilers that cause most problems
are HP's unbundled compilers and GCC, in
particular Apple's GCC releases.)
GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. There is no practical 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.
The main target applications for GMP are cryptography applications and research, Internet security applications, algebra systems, computational algebra research, etc.
GMP is carefully 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 highly optimized assembly code for the most common inner loops for a lot of CPUs, and by a general emphasis on speed.
GMP is faster than any other bignum library. The advantage for GMP increases with the operand sizes for many operations, since GMP uses asymptotically faster algorithms.
The first GMP release was made in 1991. It is continually developed and maintained, with a new release about once a year.
GMP is distributed under the GNU LGPL. This license makes the library free to use, share, and improve, and allows you to pass on the result. The license gives freedoms, but also sets firm restrictions on the use with non-free programs.
GMP is part of the GNU project. For more information about the GNU project, please see the official GNU web site.
GMP is brought to you by a team listed in the manual.
There are several categories of functions in GMP:
Complete documentation for GMP is available in the online GMP Manual. It is also available for download in a number of formats:
| DVI format | 170078 bytes bzip2'ed |
| PostScript format | 320601 bytes bzip2'ed |
| PDF format | 1002466 bytes |
The speed of GMP varies a lot on different CPUs. See the GMPbench 0.1 results, or the really obsolete GMP speed chart for details.
| Location | ||
|---|---|---|
| Sweden, gmplib.org | gmp-4.2.4.tar.bz2 | gmp-4.2.4.tar.gz |
| USA, East, ftp.gnu.org | gmp-4.2.4.tar.bz2 | gmp-4.2.4.tar.gz |
To try to verify that the file you have downloaded has not been
tampered with, you can check that the GnuPG signature matches the
contents of the file. Use your
GnuPG software or a
key server directly to get the key that
was used for creating the signature. These are the properties of the
signing key:
Name: Swox AB (Software signing key 2004) <info@swox.com>
Key ID: 0xDB899F46
Key type: 1024 bit DSA
Fingerprint: 73D4 6C36 6746 1E4B D939 7249 5D6D 47DF DB89 9F46
The GnuPG signature of gmp-4.2.4.tar.bz2 is here: ftp://ftp.gmplib.org/pub/gmp-4.2.4.tar.bz2.sig
The GnuPG signature of gmp-4.2.4.tar.gz is here: ftp://ftp.gmplib.org/pub/gmp-4.2.4.tar.gz.sig
Alternatively, you could check the MD5 checksum:
MD5 (gmp-4.2.4.tar.bz2) = fc1e3b3a2a5038d4d74138d0b9cf8dbe
MD5 (gmp-4.2.4.tar.gz) = 430f966bf8fe28d45ad8670a52b40e8c
SHA1 (gmp-4.2.4.tar.bz2) = bb721f94fbeeb8c609104540b408da6707c370ec
SHA1 (gmp-4.2.4.tar.gz) = a92b7a67543010ed917c054c01de67732b8d91a9
Since GMP is free software, anybody can improve it and pass on the result, as permitted by the GNU LGPL. 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 gmp-discuss@swox.com! For example, clever computer manufacturers should have somebody tune GMP for their processors!
If you have written an improvement, please send it to gmp-devel@swox.com so that it may be included in the next public release. If you are working on an improvement, please write to the same address, to make sure your effort is not duplicated.
There are up-to-date lists of improvements we think would be useful to many users. There are both smaller tasks and larger projects. Some of these projects have a section at the GMP development tidbits page.
Please first see the manual on how to report bugs. The FAQ below might also be useful reading. The proper address for bug reports is gmp-bugs@swox.com.
Most problems with compiling GMP these days are due to problems not in GMP, but with the compiler. In the past, system compilers caused the most trouble, but in the last years, gcc has gradually caused more and more trouble. Here, we don't list compiler problems, just problems with the GMP code itself. To save you some time, we suggest that you cut any compiler error message and paste them into your favourite web search engine before you report problems to the GMP bug report list.
| List | Subscribe URL | Archive URL |
|---|---|---|
| gmp-bugs@swox.com | http://swox.com/mailman/listinfo/gmp-bugs | http://swox.com/list-archives/gmp-bugs/ |
| gmp-announce@swox.com | http://swox.com/mailman/listinfo/gmp-announce | http://swox.com/list-archives/gmp-announce/ |
| gmp-discuss@swox.com | http://swox.com/mailman/listinfo/gmp-discuss | http://swox.com/list-archives/gmp-discuss/ |
| gmp-devel@swox.com | http://swox.com/mailman/listinfo/gmp-devel | http://swox.com/list-archives/gmp-devel/ |
The gmp-bugs@swox.com list is intended for bug reports. Please do not send general questions to that list. Information on how to write useful bug reports is available in the manual. Archives of the now obsolete bug report mailing list bug-gmp@gnu.org are available at the main GNU site http://lists.gnu.org/archive/html/bug-gmp/.
The gmp-announce@swox.com list is where important announcements from the GMP maintainers are made. All GMP users should be on this list. It is really very low volume (around one message per year).
The gmp-discuss@swox.com list is intended for discussing GMP issues with other users and developers. This is NOT for bug reports. This is the right place to ask questions, but please check the manual first.
The gmp-devel@swox.com list is for the technical discussions between GMP developers, and in general, non-developers will not be allowed to post here. Therefore, this list is moderated.
Note that we perform spam and virus filtering of these lists. The lists have been 100% spam-free during the last years.
Q1: Is there a C++ wrapper for GMP?
A1: Yes, beginning with GMP 4.0 one is bundled with the release.
Q2: When will the next release happen?
A2: See Future releases below.
Q3: I get a segfault in a program that uses GMP to calculate numbers with several hundred thousand digits. Why?
A3: Upgrade to GMP 4.2.x. (Previous version of GMP allocated huge blocks of temporary memory on the stack, causing problems for some system.)
Q4: Are there known bugs in GMP?
A4: See under "Status ..." right below.
Q5: When running make check or when trying to link my
program to gmp, I get error messages about libgcc_s.so.1. What's
the deal?
A5: As the name suggests, libgcc_s.so.1 is a gcc support
library. It is not within GMP's power to locate this file. You need to
find out why your gcc installation doesn't properly point to its internal
files.
The current release is 4.2.4, released 2008-09-19. It fixes some minor
problems found in 4.2.3. Note that we did not to work around all compiler bugs
in this release. Never forget to do
make check after building the library to make
likely it was not miscompiled!
Issues with GMP 4.2.4:
make check!
Additional issues with GMP 4.2.3:
mpf_set_str,
mpf_init_set_str, or mpf_inp_str a number with a
mantissa of larger precision than the destination variable, a buffer
overrun may occur. The overrun can be arbitrarily large. The problem is
a completely incorrect allocation in mpf_set_str (in the
file mpf/set_str), where the destination variable's precision
was used for an allocation that needed a size propotional to the string
size. Patch
Additional issues with GMP 4.2.2:
mpf_set_str,
mpf_init_set_str, or mpf_inp_str with a
base > 36, the supplied base will actually be ignored, and
the exponent 0 will be supplanted.
Patch
Additional issues with GMP 4.2.1:
mpz_set_d, arguments smaller than 1e-19 will trigger
undefined behaviour, typically a crash. Note that this is a somewhat
degenerate use of mpz_set_d that should not normally happen, since any
arguments < 1 will yield 0. Patch
mpz_popcount, mpz_hamdist, and
mpn_popcount will work unreliably when GMP is compiled with
certain compilers. The symptom is segmentation fault. This is due to a
GMP bug. Patch
mpn/generic/addsub_n.c. Second, GMP's build system
passes options such as -march=athlon or -march=pentium4, and this can of
course result in surprises for older processors.
Patch [Updated 2006-06-12 to apply more
smoothly]
Additional issues with GMP 4.2:
For patches to older GMP versions, please see the Info on older GMP releases.
There are many interesting projects that rely on GMP. Here are a few examples:
mpfr
functions are usually to prefer before GMP's own mpf
functions.
Enter an integer expression in the field below. The expression may include +, -, *, /, %, ^ (exponentiation), 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 by demos/pexpr.c from the GMP distribution.
The program generating these anagrams forms special sums representing the characters of a string, adds and compares such sums to figure out what strings can be combined. Since the sums can be several hundred bits large, GMP comes in handy.
GMP 4.3.0 will be released during 2008. It will come with speed improvements to various functions, as well as better amd64 code.
GMP 5.0 is planned to come out in a couple of years. This release will make all functions of GMP sub-quadratic, including gcd, gcdext, exact division, modular computation (by means of redc), etc. Truncating division will be improved from O(M(n)log(n)) to O(M(n)). The mpn layer will be extended to be much more complete, and mpz will as a result become simpler. More complete list: