Monday, May 30, 2005

GNU MP - arithmetic without limitations

GNU MP (a.k.a GMP) is a library written in C for arbitrary precision arithmetic. I was able to compile version 4.1 of GMP successfully in the visual c++ 6.0 environment, using its cl.exe compiler.

I followed instructions that i found in this site. You also need to download the core library from that site, where you will find patch files (such as .dsw) that lets you open a project in visual c++, and from there on you compile. To link your application program to the library, you need to include the header, and some library files that are available through a download of the static GMP library (see site).

Unfortunately, the c++ wrapper wouldn't work. I was disappointed, it wouldn't compile. However, it is safe to call the C functions from C++ in GMP. I attempted to overload the arithmetic operators, by defining my own wrapper class, that wraps around a GMP float. However, i abandoned my effort, and am currently using the mpf_xxxx functions. Its quite cumbersome to use GMP's functions. Operator overloading might be required as the number of calculation grows.

links:
GNU MP's official site
GNU MP's documentation - priceless if you are thinking of integrating GMP into your application.

No comments: