GNU Multi-Precision Library
Get GNU Multi-Precision Library essential facts below. View Videos or join the GNU Multi-Precision Library discussion. Add GNU Multi-Precision Library to your PopFlock.com topic list for future reference or share this resource on social media.
GNU Multi-Precision Library
GNU Multiple Precision Arithmetic Library
Gmplogo2.svg
Developer(s)GNU Project
Initial release1991; 28 years ago (1991)[1]
Stable release6.1.2 (16 December 2016; 2 years ago (2016-12-16)[2]) [±]
Repositorygmplib.org/repo/
Written inC, (C++, assembly optionally)
TypeMathematical software
LicenseDual LGPLv3 and GPLv2[3]
Websitegmplib.org

GNU Multiple Precision Arithmetic Library (GMP) is a free library for arbitrary-precision arithmetic, operating on signed integers, rational numbers, and floating point numbers.[3] There are no practical limits to the precision except the ones implied by the available memory (operand dimension limit is 232-1 bits on 32-bit machines and 237 bits on 64-bit machines).[4][5] GMP has a rich set of functions, and the functions have a regular interface. The basic interface is for C but wrappers exist for other languages including Ada, C++, C#, Julia, .NET, OCaml, Perl, PHP, Python, R, Ruby and the Wolfram Language. Prior to 2008, Kaffe, a Java virtual machine, used GMP to support Java built-in arbitrary precision arithmetic.[6] Shortly after, GMP support was added to GNU Classpath.[7]

The main target applications of GMP are cryptography applications and research, Internet security applications, and computer algebra systems.

GMP aims to be faster than any other bignum library for all operand sizes. Some important factors in doing this are:

The first GMP release was made in 1991. It is constantly developed and maintained.[8]

GMP is part of the GNU project (although its website being off gnu.org may cause confusion), and is distributed under the GNU Lesser General Public License (LGPL).

GMP is used for integer arithmetic in many computer algebra systems such as Mathematica[9] and Maple.[10] It is also used in the Computational Geometry Algorithms Library (CGAL) because geometry algorithms tend to 'explode' when using ordinary floating point CPU math.[11]

GMP is needed to build the GNU Compiler Collection (GCC).[12]

Examples

Here is an example of C code showing the use of the GMP library to multiply and print large numbers:

#include <stdio.h>
#include <gmp.h>

int main(void) {
 mpz_t x,y,result;

 mpz_init_set_str(x, "7612058254738945", 10);
 mpz_init_set_str(y, "9263591128439081", 10);
 mpz_init(result);

 mpz_mul(result, x, y);
 gmp_printf("    %Zd\n"
            "*\n"
            "    %Zd\n"
            "--------------------\n"
            "%Zd\n", x, y, result);

 /* free used memory */
 mpz_clear(x);
 mpz_clear(y);
 mpz_clear(result);

 return 0;
}

This code calculates the value of 7612058254738945 × 9263591128439081.

Compiling and running this program gives this result. (The -lgmp flag is used if compiling on Unix-type systems.)

    7612058254738945
*
    9263591128439081
--------------------
70514995317761165008628990709545

For comparison, one can write instead the following equivalent C++ program. (The -lgmpxx -lgmp flags are used if compiling on Unix-type systems.)

#include <iostream>
#include <gmpxx.h>

int main {
  mpz_class x("7612058254738945");
  mpz_class y("9263591128439081");

  std::cout << "    " << x << "\n"
            << "*\n"
            << "    " << y << "\n"
            << "--------------------\n"
            << x * y << "\n";

  return 0;
}

Language bindings

See also

  • GNU MPFR - library for arbitrary-precision computations with correct rounding, based on GNU MP
  • CLN - a class library for arbitrary precision
  • MPIR - a fork of GMP with mostly compatible interface which aims to provide MSVC-based compilation system for Windows platforms

References

  1. ^ "GNU MP archive". Retrieved .
  2. ^ V6.1.2 - "The GNU MP Bignum Library". Retrieved .
  3. ^ a b "What is GMP?". Retrieved .
  4. ^ Granlund, Torbjorn (2009-07-06). "Problems with mpz_set_str and huge strings". Retrieved .
  5. ^ "GMP 6.0 News". Retrieved .
  6. ^ Hughes, Andrew John (2008-02-28). "Removed GMP math?". Retrieved .
  7. ^ "GNU Classpath 0.98 "Better Late Than Never"". 2009-02-05. Retrieved .
  8. ^ "GNU MP Bignum Library". Retrieved .
  9. ^ "The Mathematica Kernel: Issues in the Design and Implementation". October 2006. Retrieved .
  10. ^ "The GNU Multiple Precision (GMP) Library". Maplesoft. Retrieved .
  11. ^ "CGAL Manuals".
  12. ^ GCC uses the GNU MPFR library, which in turn relies on GMP. "GCC 4.3 Release Series: Changes, New Features, and Fixes". 2012-11-02. Retrieved .

External links


  This article uses material from the Wikipedia page available here. It is released under the Creative Commons Attribution-Share-Alike License 3.0.

GNU_Multi-Precision_Library
 



 



 
Music Scenes