Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an arbitrary precision floating point library for C/C++ which allows arbitrary precision exponents?

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.

like image 325
user1743775 Avatar asked Oct 13 '12 18:10

user1743775


People also ask

Does Python have arbitrary precision?

Generally, In low-level languages like C, the precision of integers is limited to 64-bit, but Python implements Arbitrary-precision integers.


2 Answers

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.

like image 187
Marc Mezzarobba Avatar answered Sep 26 '22 07:09

Marc Mezzarobba


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).

like image 33
Stephen Canon Avatar answered Sep 27 '22 07:09

Stephen Canon