Reputation: 67234
I'm looking for an MSVC++ specific arbitrary precision library. Since I don't need cross platform compatibility for what I'm working, I'd rather not have the mess of it all.
I tried looking at NTL but upon seeing statements like "These steps work with MSVC++ v6" I can't help but mentally bury it as out of date. Latest build: 2009 08 14
.
MPIR looks promising (latest build 2011 06 14
), its the best thing I found so far.
Any suggestions for doing at least 128-bit floating point arithmetic from MSVC++ (native code, not .NET)?
Upvotes: 5
Views: 3247
Reputation: 80272
MPIR can be compiled with Visual Studio 2017.
Brian Gladman maintains a fork of MPIR that builds nicely with Visual Studio: https://github.com/BrianGladman/mpir
# Open a "Visual Studio x64 Native Tools Prompt"
cd C:\github
git clone https://github.com/BrianGladman/mpir
cd mpir\msvc\vs17
msbuild gc lib x64 release
Also try running the gen_*.bat
files in that same directory if this does not work.
It will also need a Windows SDK.
Brian also maintains a fork of MPFR that builds under Visual Studio: https://github.com/BrianGladman/mpfr
Boost also includes C++ bindings for MPFR and GMP multi-precision libraries. Boost is well-maintained and will compile without much trouble within any version of Visual Studio.
Upvotes: 1
Reputation: 67234
MPIR is the best C++ multi-precision (arbitrary precision) arithmetic library available right now. The fact that it is cross-platform is a plus. It is easy to compile on MSVC++ 2010, you just have to make sure to open README.TXT (that comes with the download) and also read the Documentation, (which is quietly listed as the 3rd download in the list but is actually quite good).
It is based on GMP and supercedes NTL, which should be all but abandoned because its not being maintained.
MPIR has builds and assembly code for a large number of CPUs, including like a ton of Intel and AMD chips.
One hitch I encountered in the build process (on 2 separate machines!) was the CPU type was not identified correctly. On one machine I had a "k102" processor (which can be considered "k10") and on another machine I had "westmere" (which could be considered as "nehalem"). Anyway the fix is BROWSE CONFIGURATION.BAT and look for your CPU type. When you invoke "configure.bat", use a line like:
configure --cpu-k10
If you know you have an AMD k10 compatible CPU. This happened with a AMD 1090T processor.
Upvotes: 5