note
syphilis
<i>Eventually, I found mpfr which lets you set how many digits of precision you want to use.</i><br><br>Then there's really no need to look further - it's an excellent library. Incidentally, I placed a module (Math::MPFR) on CPAN that wraps the documented mpfr functions. I think I'm the only person that uses it. If you ever take a look at it, I'd be interested on any feedback. I believe it functions well, but there are aspects which bother me - eg, the documentation, the naming of the functions, and the fact that I wrote all of the XS functions "longhand" (as opposed to using a typemap). <br><br>Anyway ... back to the consideration of long doubles. Recent versions of mpfr allow you to convert directly from an mpfr_t to a long double, so one could do something like the following:<code>
mpfr_t mpfr_pi;
long double ld_pi;
mpfr_set_default_prec(sizeof(long double) * 8);
mpfr_init(mpfr_pi);
mpfr_const_pi(mpfr_pi, GMP_RNDN);
ld_pi = mpfr_get_ld(mpfr_pi, GMP_RNDN);
</code>
I would expect that ld_pi and mpfr_pi would contain the same value, though there's no guarantee that I'm correct. I was actually hoping to have a bit of a play with this at work tonight, but a last minute breakdown made a complete mess of that plan. (I may yet take a closer look and send you an /msg, as it's not really on-topic for either this forum or this particular thread). <br><br>Perhaps long doubles <b>don't</b> provide the precision that I expect - I've never checked. Or perhaps it's just an issue with printf or a general problem with C (as you suggested). Or perhaps it's just an issue with Glib. It would be interesting to know ....<br><br>Cheers,<br>Rob
598007
598198