Getting greatest decimal accuracy out of G_PI



Hi,
Please pardon my basic questions, but I am self taught
and run into questions I can't solve thru googling.

I see that G_PI is defined in the header to
3.14159265358979323846

So on my 32 bit Athlon machine, I get limited precision
to 15 decimal places, do I need a 64 bit machine for better
precision? Or is there a different format to use?

#include <gtk/gtk.h>

int  main (){                                                                                         
/* #define G_PI    3.14159265358979323846E0  */
  gdouble PI = G_PI;

  g_print("3.14159265358979323846\n");
  g_print("%0.20e\n",G_PI);
  g_print("%0.20f\n",G_PI);
  g_print("%0.20f\n",PI);
  g_print("%0.20g\n",PI);
  g_print("%0.20e\n",PI);
 
return 0;                                                                         
}  

Output gets limited to 15 decimal places
3.14159265358979323846           in header
3.14159265358979311600e+00   various formatted
3.14159265358979311600            .....
3.14159265358979311600            .....
3.141592653589793116                .....

Thanks.

zentara

-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]