mpf_get_str function

matteo mat matteo.web73 at gmail.com
Fri Mar 15 19:57:49 CET 2013


"Hello World" I'm new here and as many new users I have a question.. I have
a lot of problems with the function mpz_get_str ... Thought it was because
of me but I found this code and tried to compile it:

#include <stdio.h>            /* for printf */
#include <gmp.h>

int main(int argc, char *argv[])
{
  mpz_t a, b;                         /* working numbers */
  if (argc<3)
    {                    /* not enough words */
    printf("Please supply two numbers to add.\n");
    return 1;
  }
  mpz_init_set_str (a, argv[1], 10);    /* Assume decimal integers */
  mpz_init_set_str (b, argv[2], 10);    /* Assume decimal integers */
  mpz_add (a, a, b);            /* a=a+b */

  printf("%s + %s => %s\n", argv[1], argv[2], mpz_get_str (NULL, 10, a));
  return 0;
}

so the output was:

3.234 + 3.456 => 0

don't know why mpz_get_str give me this... and even the mpf one is telling
the same joke


More information about the gmp-discuss mailing list