logo
vision scalability social networking revelation source

Multiprecision Arithmetic

I will need multiprecision arithmetic if I represent information in a base or dictionary that is not a power of two.

The best libraries are GMP for Linux and MPIR for windows. These are reasonably compatible, and generally only require very trivial changes to produce a Linux version and a windows version. Boost attempts to make the changes invisible, but adds needless complexity and overhead in doing so, and obstructs control. MPIR has a Visual Studio repository on Github, and a separate Linux repository on Github. GMP builds on a lot of obscure platforms, but not really supported on Windows.

For supporting Windows and Linux only, MPIR all the way is the way to go. For compatibility with little used and obscure environments, you might want to have your own custom thin layer that maps GMP integers and MPIR integers to your integers, but that can wait till we have conquered the world.

My most immediate need for MPIR is the extended Euclidean algorithm for modular multiplicative inverse, which it, of course, supports, mpz_gcdext, greatest common divisor extended, but which is deeply hidden in the documentation.

Creative Commons License reaction.la gpg key 154588427F2709CD9D7146B01C99BB982002C39F
This work is licensed under the Creative Commons Attribution 4.0 International License.