GNU Multiple Precision Arithmetic Library
The GNU Multiple Precision Arithmetic Library is a programming library that implements arithmetic functions for arbitrary precision / large numbers. The first version of GMP appeared in 1991. Since the library is constantly being expanded and improved and edited in an annual release. GMP is an official part of the GNU project, is under the LGPL license and is thus free software.
Restrictions
The possibilities of GMP in relation to the size of the numbers is unique and limited only by RAM or virtual memory available to the computer. Despite the emulation of the hardware calculations in the form of software algorithms GMP remains relatively quickly, as has been optimized at many points with the help of assembler instructions.
Functions
Features of GMP is divided into seven categories.
- Arithmetic and logical functions for signed integer (about 140 functions)
- Arithmetic on rational numbers (about 35 functions)
- Arithmetic functions for floating point numbers ( 65 functions)
- C wrapper classes for the above functions
- Arithmetic functions for unsigned integers, for which the user must implement the memory management itself
- Functions on the rounding of floating-point numbers
- Functions for compatibility with the Berkeley MP project
Example of usage
The GMP has three main types of data: mpz_t ( arbitrarily large integers ), mpf_t ( arbitrarily large floating-point modifiable, even extremely high precision ) and mpq_t ( representation of numbers as a fraction ). The GMP variables can not simply be assigned values ( like normal data types), but it need special functions are called (see listing). The following code illustrates the basic use of the GMP:
# Include
# Include
- Official website including GMP documentation in HTML and PDF
- Official of the GNU Project website
- MPIR - A Fork of libgmp to better support Microsoft Windows
- Library (programming)
- Computer arithmetic
- GNU