Merci pour le lien godrik, en effet j'ai réussi à l'installer.
Par contre j'ai toujours un problème. En fait, je veux un logiciel qui calcule le nombre de champernowne
(0.12345678910111213141516171819202122232425....)
Mais avec le code que j'ai, j'ai 0.12345679012345679012345679012..., au lieu de continuer vers 10, 11 etc..., ça revient à 0 (en plus y'a le 8 qui disparait mystérieusement...
Voici le code que j'ai :
- include <cstdlib>
- include <iostream>
- include <gmp.h>
using namespace std;
int main(int argc, char *argv[])
{
int n=1000; //approximation de l'affichage
int i=0;
int j=900; //décimales à calculer
mpf_t a; // pour declarer un grand flottant a
mpf_t b; //
mpf_t c; //
mpf_t d;//
mpf_init2 (a,1024); // pour allouer la memoire necessaire au flottant
mpf_init2 (b,1024); //
mpf_init2 (c,1024); //
mpf_init2 (d,1024); //
mpf_set_str (a, "0",10); // a = 0
mpf_set_str (d, "10",10); // d = 10
for (i=0;i<j;i++)
{
mpf_pow_ui (b,d,i); // b = 10^i
mpf_ui_div (c,i,b); // c = i/b
mpf_add (a,a,c); // a = a+c
}
gmp_printf ("%.*Ff with %d digits\n", n, a, n);
mpf_clear(a); // liberer l'espace allouer a a !
mpf_clear(b); // liberer l'espace allouer a a !
mpf_clear(c); // liberer l'espace allouer a a !
system("PAUSE");
return EXIT_SUCCESS;
}