-1

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 <stdio.h>
#include <gmp.h>

int main() {
    mpz_t x;
    mpz_t y;
    mpz_t result;

    mpz_init(x);
    mpz_init(y);
    mpz_init(result);

    mpz_set_str(x, "762323423423423443534512034534534534558254738945", 10);
    mpz_set_str(y, "92635911345345345345234534534534567767i888439081", 10);

    mpz_mul(result, x, y);
    gmp_printf("%Zd\n", result);

    mpz_clear(x);
    mpz_clear(y);
    mpz_clear(result);

    return 0;
}

The result is.. 0. Why?

Eve Freeman
  • 32,467
  • 4
  • 86
  • 101
marxin
  • 3,692
  • 3
  • 31
  • 44

1 Answers1

3

At first it looked fine, so I had to run it myself and print out your other two variables.

y is set to 0 because you have a letter "i" in the middle of your number, so it can't parse it.

Eve Freeman
  • 32,467
  • 4
  • 86
  • 101