1

I was attempting to multiply two very large mpz_ts together, each of 2^(10*2^22) bits, using the mpz_mul function in the GMP library.

There was no segmentation fault, and the multiplication managed to go through. However, when I output the result of the multiplication to a file, all I observed is a string of trailing zeros.

Is there any way I can overcome this limitation?

CSᵠ
  • 10,049
  • 9
  • 41
  • 64
meta_warrior
  • 389
  • 1
  • 6
  • 18
  • How are you printing to a file? You are using gmp functions only, right?? It will be better if you could post the code!!! – Arpit Sep 12 '14 at 00:30
  • I am just using gmp_fprintf to output the results to a file in GMP. @Arpit – meta_warrior Sep 12 '14 at 00:40
  • 5
    I can't tell you like this unless you post the code. Try printing it on console or try other values. Debug it. – Arpit Sep 12 '14 at 00:43
  • 3
    Hang on, *how* many bits? 2^(10*2^22) is 2^41943040. I hope that's not how many bits you have. (More realistically, I would guess you have two 42MBit numbers...) – nneonneo Sep 12 '14 at 00:45
  • What do you mean, trailing zeroes? If there's a 1 anywhere, then the number is just divisible by a large power of 2. – Potatoswatter Sep 18 '14 at 22:50

1 Answers1

-1

How about bn lib (this library performs arithmetic operations on integers of arbitrary size) ?! You can use bn library and convert the result to GMP's value.

zh_
  • 95
  • 8