I would like to be able to express decimal fractions (i.e. m * 10^{-k} for integers m,k ) with exact precision - as opposed to what we have with binary floating-point values. Essentially there are two options: Floating-point, but decimal (as in this proposal), or fixed point with only the mantissa stored.

So I'm after a library which implements one of these options, or both, reasonably.


  • Gratis
  • Header-mostly
  • LGPL or similar lax FOSS license
  • Not abandoned


  • Header-only
  • As fast as one could expect given the lack of hardware support for this
  • Well-documented
  • C++11/C++14-oriented
  • No significant external dependencies

2 Answers 2


You could look at The GNU Multiple Precision Arithmetic Library (GMP) possibly with The GNU MPFR Library which are C libraries for multiple-precision floating-point computations with correct rounding.

There are bindings for C++ and other languages.

  • Gratis
  • Open Source GNU Lesser General Public License (LGPL v 3)
  • Latest release at the time of writing: GMP 16 December 2016 & MPFR 27 September 2016 but the VCS shows checkins this week for both.
  • Documentation looks good
  • MPFR depends on GMP
  • IIANM, The GMP library does not offer either one of the types I asked for. The closest thing they offer are rationals and that's not really what I'm after.
    – einpoklum
    Commented Jul 21, 2017 at 19:22

It sounds like you are looking for the mpdecimal package or its underlying libmpdec library, which is "a complete implementation of the General Decimal Arithmetic Specification".

Moreover, the proposal page you linked to already lists some other implementations, notably from Intel and IBM.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.