Is there an arbitrary precision floating point lib

2019-04-20 10:04发布

问题:

I'm looking for an arbitrary precision floating point library for C/C++ (plain C is preferred). I need arbitrary precision exponents. GMP and MPFR use fixed size exponents, so they are ineligible (I have some ideas for workarounds, but I prefer an out-of-the-box solution). It would be an nice feature if the exponent precision can be adjusted automatically to prevent infinity-values.

If you know for sure that such an library does not exist, please say so.

回答1:

There is nothing as mainstream as GMP/MPFR as far as I know. But Fredrik Johansson's arb contains a module called fmpr that provides floating-point numbers with arbitrary precision exponents.



回答2:

That's a pretty specialized request; without knowing more about your actual needs, I might consider using a more common arbitrary-precision library like MPFR to represent the logarithms of your values (which doesn't quite give truly arbitrary exponent range, but does get you exponents so large that it's probably no longer an issue).



回答3:

You might take a look at http://www.ttmath.org/ - I don't think it can adjust precision on-the-fly, but it does support arbitrary precision reasonably well.