Search code examples
cfloating-pointprecisionfloating-accuracy

How to define a floating-point data type larger than 16 bytes?


I'm trying to do math calculations that they require more than 100 decimals of precision. C data types cannot go beyond 16 bytes (long double), so I cannot compute more than ~17 decimals. Is there a way to create a variable in C that can get more precision?


Solution

  • Realistically you need an arbitrary-precision arithmetic library, see Wikipedia for some options. I personally have found GNU MPFR to be fairly reliable, though I have also heard good things about Arb.