gmp

GMP convert mpz to mpf

I am using GMP, and I want to be able to quickly convert an mpz to an mpf. I looked through the library and couldn't find much. The best thing I could think of was this: mpz_t x; /* Insert code here that assigns some value to x */ char buf[SIZE]; gmp_sprintf(buf, "%Zd", x); mpf_t y; mpf_set_str(y, buf); This solution requires repeate...

GMP arthimetic operations

As we know GMP is the most popular tool for handling laarge intergers... i have two questions regarding GMP.. 1.how does internal calculations will be done in GMP library.? suppose if one integer of two bytes,another of three bytes what are the operations performed internally on those raw bits!?? 2.How does performance speed is high for ...

GMP ..binary execution

In GMP library.... how does internal execution of operations on integers ll be done?? like 6=0110,4=0100..and 6+4= 0110+0100.. what happens in case of multiplications,division and other operations!?? how does it controls overflow bits and other things ... ...

GMP-Assembly code???

Where i can find ASSEMBLY code for my program written for gmp-5.0.0 im using UBUNTU and G++ compiler.. command for compiling the code is "g++ test.cc -o outp -lgmp" actually i want to know what happens internally in terms of 1's and 0's... how the memory allocation will takes place and how the operations will performed on RAW bits!! ...

How do you write a bigint library / how does libgmp work?

Hi All, I'm aware of a number of BigInt libraries for C on various platforms and how to use them but I'm intrigued: how do they work? How would I go about building my own library (I'm not going to try, no point re-inventing the wheel but I'm interested in how it might happen)? Can anyone point me towards tutorials etc that might explain...

How can I convert this C++ function from using long to this other type?

I have this original C++ function called "s": long s(long n) { long sum = 0; long m; m = (long) sqrt(n); for (long i = 2; i < m; i++) if ((n % i) == 0) sum += (i + (n/i)); if (n>1) sum += 1; if ((m*m) == n) sum += m; return sum; } I've been struggling to convert this function over to using the GMP's mpz type, so tha...

Why I cannot use my GMP library in Linux

Hi, I was writing some codes in linux using c. When tried to compiled, I got this response: /tmp/ccW8mQDx.o: In function `main': server.c:(.text+0x3e): undefined reference to `__gmpz_set_str' server.c:(.text+0x5a): undefined reference to `__gmpz_set_str' In fact, all the functions of gmp that I used couldn't be found. Seems there ar...

How to cut a mpz_t into two parts using GMP lib on C?

Using GMP on c, I have a big integer "mpz_t n" in decimal form, how can I cut it into 2 parts? In fact, these 2 parts should have the same length in binary. For example, maybe I can convert the n to a binary of 112bits, then I want to cut it into 2 56bits parts. Thanks ...

Is GMP broken? It can't be done!!!

When I call get_d() on a MPQ variable in the GMP library, I only get at most six digits. C++ is supposed to provide 8 bytes or ~15 digits for doubles. Why am I only getting six digits? ...

Selection of parameters in Diffie-Hellman

Hello, maybe it's not so proper to ask this question here... anyway, I'm trying to use the gmp library for the implementation of DH, but the problem here I got is: Once, when I was doing the tests to observe the output, although big values of prime and the private keys were selected: p was about more than 300 digits long in decimal a...

Custom types in OpenCL kernel

Is it possible to use custom types in OpenCL kernel like gmp types (mpz_t, mpq_t, …) ? To have something like this (this kernel doesn't build just because of #include <gmp.h>) : #include <gmp.h> __kernel square( __global mpz_t* input, __global mpz_t number, __global int* output, const unsigned int count) { int i = get_g...

GMP variable's bit size..

How to know the size of a declared variable in GMP??or how can we decide the size of an integer in GMP? mpz_random(temp,1); in manual it is given that this function allocates 1limb(=32bits for my comp) size to the "temp".... but it is having 9 digit number only.. SO i dont think that 32 bit size number holds only 9 digits number.. So ...

GMP variable's bit size..

In GMP library, _mp_size holds the number of limbs of an integer.. we can create integers of size 1 limb(32bits),2 limbs(64bits),3 limbs(96bits)...so on. using mpz_init or mpz_random functions.. cant we create an integer variable of size 8bit or 16 bit.. other than multiples of 32 bit size ??? can you code for that?? thank you .. ...

GMP Vs java BIG INTEGERS,,,

Which tool is the best one for accesing large bit numbers for testing Crypto systems..either GMP library or JAVA big integers..?? in terms of speed, memory, functions, flexibility towards crptosystems(mathematical functions like invert,pwm..etc). ...

Using GHC, cabal with GMP installed in user-space

I have been trying to install Haskell Platform and cabal-install installed on Linux in user-space on a system that doesn't have the GNU Multi-Precision package (GMP) installed. I managed to get GHC-6.12.1 installed and ghci working by setting up LB_LIBRARY_PATH to point at the lib directory where I installed GMP, but then ran into probl...

The best cross platform (portable) arbitrary precision math library

Dear ninjas / hackers / wizards, keywords: bignum, bigint, GMP, MPFR, decNumber, BigInteger, BigDecimal, java.math.BigInteger, java.math.BigDecimal, System.Numerics.BigInteger I'm looking for a good arbitrary precision math library in C or C++. Could you please give me some advices / suggestions? The primary requirements: It MUST ha...

Making pascal's triangle with mpz_t's

Hey, I'm trying to convert a function I wrote to generate an array of longs that respresents Pascal's triangles into a function that returns an array of mpz_t's. However with the following code: mpz_t* make_triangle(int rows, int* count) { //compute triangle size using 1 + 2 + 3 + ... n = n(n + 1) / 2 *count = (rows * (rows + 1)) / 2; m...

From float to mpz_t

I am using GMP in C. Is it possible to set a mpz_t to the value of a float? ...

Problem installing PEAR package with GMP extension requirement

I want to install the Crypt_DiffieHellman PEAR package, that gives me the following error: pear/Crypt_DiffieHellman requires PHP extension "gmp" So I installed the gmp extension (using MacPorts' "php5-gmp"), both php -m and extension_loaded('gmp') indicate that the extension is loaded. However I still get the PEAR error when I try to ...

Using gdb with GMP variables

I am debugging some C code with gdb. My program has a variable of type mpz_t * retval. If I run the command print *retval I get the output $23 = {{ _mp_alloc = 6, _mp_size = 5, _mp_d = 0x1001008d0 }} Is there anything else I can do to get more information about the value stored in retval? ...