Wrong division ?

Di Maria Giovanni calimero22 at yahoo.it
Fri Apr 1 11:57:31 UTC 2016


Hi.

Version of GMP: gmp-6.1.99-20160330

I have create  a float division between two factorials, in GMP as follow:

50! / 120!


GMP gives:
0.000.......4546540093519711704355108480114153379661....

SAGE, Wolfram Alpha, PARI/GP and BC give:
0.000.......4546540093519711704355108480114153355262....

Is it normal?
Thank you very much.
Giovanni Di Maria

PS.
Here is the code:

#include <stdio.h>
#include <gmp.h>
int main(void) {
   mpz_t x,y;
   mpf_t xx,yy,divisione;
   mpz_init(x);
   mpz_init(y);
   mpf_init(xx);
   mpf_init(yy);
   mpf_init2(divisione,50000);
   mpz_fac_ui(x,50);
   mpz_fac_ui(y,120);
   mpf_set_z(xx,x);
   mpf_set_z(yy,y);
   mpf_div(divisione,xx,yy);
   /*-----Print-----*/
   printf("\n\n\n\n\n");
   gmp_printf("%4.1000Ff\n",divisione);
   mpz_clear(x);
   mpz_clear(y);
   mpf_clear(xx);
   mpf_clear(yy);
   mpf_clear(divisione);
   return 0;
}




More information about the gmp-discuss mailing list