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
-1
votes
1 answer

Composer error - GMP

While i want to install composer I have error: I have installed GMP on my mac - i see it in folder + while i use "brew search gmp" i see checkmark. So its all all right. I have also enabled in php.ini extension=gmp.so extension=php_gmp.so I really…
Albert
  • 11
  • 5
-1
votes
1 answer

I need help implementing bigger more precise floats. (Mandelbrot Renderer)

__float128 is way too slow I am not experienced in GMP or MPFR what so ever. Is there anything I could do? this is a very cut down version of my code. The cut down code is missing many elements: Code I'm new to stack overflow #include…
Spl1ce
  • 9
  • 1
-1
votes
1 answer

Where does GMP get installed to by default on Mac High Sierra?

I just downloaded the tar.bz2 file for GMP 6.1.2 on Mac High Sierra. After configuring, making, and installing everything without errors, I couldn't figure out what my path to GMP actually was. The web site said my default path would be…
Dave
  • 15,639
  • 133
  • 442
  • 830
-1
votes
1 answer

GMP in kernel Module

I'm quiet new to module coding and I need to run some calculation that uses the GMP library in a module. So the first question: is it generally possible to run GMP in kernel? For testing, I wrote this Module: #include #include…
Balltasar
  • 1
  • 1
-1
votes
1 answer

How to use placeholders for unneeded parameters in c++

I am using this function from the GMP arbitrary precision arithmetic library: Function: void mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t a, const mpz_t b) Set g to the greatest common divisor of a and b, and in addition set s and t to…
Saul Femm
  • 17
  • 3
-1
votes
2 answers

Using Malloc to handle large numbers with GMP

Solved: I feel so stupid. GMP is fine and it was my oversight. After using size_t mpz_sizeinbase (const mpz_t op, int base), I realised my char array I used to copy the result into was too small. Increasing it size solved it. Thanks for the…
-1
votes
1 answer

GMP (GNU Multiple Precision) : "mpz_mod" function error

Can anyone help me with this? The function "mpz_mod" is wrong but i don't know how to fix it. #include #include #include using namespace std; int main () { mpz_class p; mpz_class y; mpz_class m; for ( p=100 ;…
dimig
  • 1
  • 3
-1
votes
1 answer

Modulo negative floats using "%" and gmp_mod does not work

I try to get the result of -0.15 modulo 5 in PHP. Following codes always return 0. $mod = ((-0.15) % 5) $mod = (-0.15 % 5) $mod = gmp_mod("-0,15", "5"); $mod = gmp_mod(-0.15, 5); When I type "-0.15 mod 5" into google, it returns: 4.85 What is…
Kia
  • 301
  • 3
  • 11
-1
votes
2 answers

Error with GMP with C++ in Netbeans (Windows 64-Bit)

I'm doing a project for school in which I am doing all kinds of different calculations involving prime numbers. These numbers tend to go quite big, hence I went looking for an arbitrary precision library. I decided to go for GMP since I had used it…
Jelle
  • 36
  • 6
-1
votes
1 answer

GMP integer size limit reached?

I have written an implementation of Toom multiplication with GMP. I tested multiplication of 2 numbers of around 7000 digits (23,000 bits) and it worked perfectly. However when I tried it with 70000 digits (230,000 bits) the program started…
qwr
  • 9,525
  • 5
  • 58
  • 102
-1
votes
1 answer

i need to take an mpir integer and output it into a char buffer

i have recently installed mpir and have the following code (c++) visual studio. char buffer[100] mpz_t x; mpz_set_str(x, "7612058254738945", 10); I would like to print x into the buffer. used to use sprint but there does not seem to be any sprint…
david
  • 11
  • 1
-1
votes
1 answer

C++ GMP: What is the difference between mpq_t and mpf_t >

I am trying to decide which to use with the modular inverse function of GMP, and I can't seem does find the difference between mpq_t and mpf_t. The GMP manual mentions — Function: void mpz_set_q (mpz_t rop, const mpq_t op) — Function: void…
user2059300
  • 361
  • 1
  • 5
  • 17
-1
votes
1 answer

C GMP unlimited precision - what i am doing wrong?

i have such code (copy paste from wiki). Its multiplication of those big numbers what u see in code. My gmp version is 5.0.5. #include #include int main() { mpz_t x; mpz_t y; mpz_t result; mpz_init(x); …
marxin
  • 3,692
  • 3
  • 31
  • 44
-2
votes
1 answer

GMP Library issue

I am new to GMP Library. I am doing something like this: mpz_t c; mpz_init(c); mpz_set(c, 101511210056003611542252000); This last line gives me warning ⚠️. Is it not allowed? If not, how should I assign such large value to this variable? PS: If I…
Qasim
  • 1
  • 1
-2
votes
1 answer

GMP mpz_t variable being set with incorrect value

I've been working on the Euler 29 problem for a few days and am having difficulty getting the mpz_t type to work correctly. The objective is to iterate through a^b for values of 2 <= a,b <= 100 and count the nonrepeat values. Using vector I was able…
MFerguson
  • 1,739
  • 9
  • 17
  • 30