Questions tagged [gmp]

The GNU Multiple-Precision Library (GMP) is a mature, free library for arbitrary-precision arithmetic with support for big signed integers, rational numbers, and floating point numbers. The basic interface is for C but wrappers exist for other languages including Ada, C++, C#, OCaml, Perl, PHP, and Python. It is distributed under the GNU LGPL and is used for cryptography applications and in computer algebra systems such as Mathematica and Maple.

GMP, or GNU Multiple Precision Arithmetic Library, is a library allowing for arbitrary precision arithmetic. This means that calculations using the libraries internal variables are not limited to ordinary constraints of bit-level precision that many languages inherently possess.

It can support multiple different data types including floating-point numbers, signed integers and rational numbers. It is primarily used in areas related to cryptography, and is also heavily used in numerical research, other types of security applications and computational algebra.

Full words are used as the intrinsic data type, and logic is used to select separate algorithms depending upon the operand size for efficiency purposes. Critical parts of the library utilize Assembly code and is specialized for different processing units to further increase efficiency.

GMP is designed to run on systems running Unix derivates including Linux and Solaris, but may also work on 32-bit and 64-bit Windows machines.

The manual and information to get started using GMP are located here :

https://gmplib.org/manual/

1024 questions
7
votes
3 answers

Square root of bignum using GMP

I need to get the square root of a 210 digit number accurately, I thought GMP was the right tool for the job, what am I doing wrong? #include #include #include "gmp.h" int main (int argc, char *argv[]) { mpz_t sq_me, sq_out,…
YHVH
  • 585
  • 4
  • 12
7
votes
2 answers

Error when statically linking libgmp on Linux

The GMP docs say that static linking may provide a small performance improvement. I am having a problem getting it to staticly link libgmp on my Linux systems. I've narrowed down the issue I'm having to a tiny test case. gmptest.c #include…
fadedbee
  • 42,671
  • 44
  • 178
  • 308
7
votes
1 answer

How to use find_package in CMake? (Example: GMP library)

I'm trying to use find_package to include libraries in CMake. This question talks about how to tell CMake to link to the GMP library (external). I am trying to follow the steps of the answer there but do not have any of the Config.cmake or…
Adomas Baliuka
  • 1,384
  • 2
  • 14
  • 29
7
votes
2 answers

mpz_t to unsigned long long conversion (gmp lib)

Is there a way to convert a mpz_t variable to unsigned long long in C?How about the other way around,from ull to mpz_t?The gmp library doesn't support this as ull are part of C99. I found this but it's in c++,and I don't know how to code in…
kaiseroskilo
  • 1,719
  • 4
  • 21
  • 29
7
votes
4 answers

cmake build failed on macos catalina 10.15

I have recently installed macos catalina with Xcode 11.1 and updated cmake, clang and llvm sudo rm -rf /Library/Developer/CommandLineTools xcode-select --install $ cmake --version cmake version 3.15.4 $ which cmake /usr/local/bin/cmake $ clang…
Gajaka
  • 71
  • 1
  • 2
7
votes
1 answer

Is there any way of doing multiprecision arithmetic(with integers that are greater than 64-bit) in msp430?

I'd like to know if there is any way, if possible any simple way, to do arithmetic with integers that are larger than 64-bit in size on MSP430? I'm asking this specifically because I'm trying to implement encryption algorithms (RSA, AES, hash…
Nae
  • 14,209
  • 7
  • 52
  • 79
7
votes
3 answers

How to implement long division for enormous numbers (bignums)

I'm trying to implement long division for bignums. I can't use a library like GMP unfortunately due to the limitations of embedded programming. Besides, i want the intellectual exercise of learning how to implement it. So far i've got addition and…
Chris
  • 39,719
  • 45
  • 189
  • 235
7
votes
1 answer

Why does gcc require gmp?

As anyone who has ever built gcc from source knows, gmp is a dependency for gcc. Why is this? In other words, what does gcc actually use it for?
Brian Bi
  • 111,498
  • 10
  • 176
  • 312
7
votes
1 answer

Are there any advantages to GMP over MPIR?

Both seem to be decent bignum libraries but I am not sure what the pros/cons of each are. I know this is a broad question but I am mostly after the prominent differences.
KaliMa
  • 1,970
  • 6
  • 26
  • 51
6
votes
2 answers

Build GMP for iOS

I need to use GMP in an iphone program I'm working on, but don't really know where to begin. I know that I have to build a version for the device and a version for the simulator, but that is as much as I know. I've tried looking around but haven't…
user1178964
  • 85
  • 2
  • 6
6
votes
3 answers

Does anyone have a working GMP + MINGW installation?

I've spent days and days trying to install GMP library on my MINGW windows installation. I completed the installation process of both dozens of times, followed any single guide on the internet but I couldn't manage to get things working. So, I'm…
Matteo Monti
  • 8,362
  • 19
  • 68
  • 114
6
votes
2 answers

Efficient code to do set operations with bigz-class values?

The current release of the package gmp does not support set operations such as intersect, setdiff , etc. I'm doing some work with number sequences (see OEIS for examples) and need to handle large collections of large integers. I'm currently…
Carl Witthoft
  • 20,573
  • 9
  • 43
  • 73
6
votes
1 answer

gmp shared libraries not found

I have a very simple GMP program in C (below) #include #include int main() { mpf_t a, b, inter; mpf_init(a); mpf_init(b); mpf_init(inter); mpf_set_d(a, 3.0); mpf_set_d(b, 5.0); mpf_add(inter, a, b); …
tekknolagi
  • 10,663
  • 24
  • 75
  • 119
6
votes
3 answers

Large integer radix/base conversion from 10^x to 2^x

Preface I'm learning about computer math by writing and refining my own BigInt library. So far my first incarnation stores every digit of a base 10 number in successive elements of a vector. It can multiply and add with arbitrary precision. I want…
frontendloader
  • 365
  • 4
  • 12
6
votes
1 answer

Android NDK compile gmp library

How to compile GMP for android ndk as a static or shared library that I can reuse in my projects/
joshjdevl
  • 7,092
  • 12
  • 45
  • 57