They are based on GMP developed by T. Granlund [GMP], MPFR developed by
P. Zimmermann [MPFR], and MPC an extension of complex numbers
by D. Bini and G. Fiorentino.
- Scl<MPZ>
which corresponds to big integers, based on the GMP type mpz.
- Scl<MPQ>
which corresponds to big rational, based on the GMP type mpq.
- Scl<MPF>
which corresponds to big floats, based on the GMP type mpf.
- Scl<MPFR>
which corresponds to reliable big floats, based on the MPFR library.
- Scl<MPC>
which corresponds to big complexes, based on the type mpc.
Example
#include "bignum.H"
typedef Scl<MPZ> BZ;
typedef Scl<MPF> BF;
typedef Scl<MPQ> BQ;
int main(int argc, char** argv) {
//Big floats
BF pf("1000232325454545232322343421111111434343435555"),
qf(25555),rf;
cout<<"pf = "<<pf<<endl;
pf = 0.1000232325454545232e46
cout<<"qf = "<<qf<<endl;
qf = 0.25555e5
rf =pf*qf; cout<<"pf*qf= "<<rf<<endl;
pf*qf= 0.2556093707699090341e50
rf =pf+qf; cout<<"pf+qf= "<<rf<<endl;
pf+qf= 0.1000232325454545232e46
rf =pf-qf; cout<<"pf-qf= "<<rf<<endl;
pf-qf= 0.1000232325454545232e46
rf =pf-qf; cout<<"-qf = "<<rf<<endl;
-qf = 0.1000232325454545232e46
rf =pf/qf; cout<<"pf/qf= "<<rf<<endl;
pf/qf= 0.3914037665640951799e41
//Big integers
BZ pz("1000232325454545232322343421111111434343435555"),
qz(25555),rz;
cout<<"pz = "<<pz<<endl;
pz = 1000232325454545232322343421111111434343435555
cout<<"qz = "<<qz<<endl;
qz = 25555
rz =pz*qz; cout<<"pz*qz= "<<rz<<endl;
pz*qz= 25560937076990903411997486126494452704646495608025
rz =pz+qz; cout<<"pz+qz= "<<rz<<endl;
pz+qz= 1000232325454545232322343421111111434343461110
rz =pz-qz; cout<<"pz-qz= "<<rz<<endl;
pz-qz= 1000232325454545232322343421111111434343410000
rz =pz-qz; cout<<"-qz = "<<rz<<endl;
-qz = 1000232325454545232322343421111111434343410000
rz =pz/qz; cout<<"pz/qz= "<<rz<<endl;
pz/qz= 39140376656409517993439382551794616879023
rz =pz%qz; cout<<"pz\%qz= "<<rz<<endl;
pz%qz= 2790
rz+=(pz*qz);cout<<"rz+=(pz*qz)= "<<rz<<endl;
rz+=(pz*qz)= 25560937076990903411997486126494452704646495610815
rz-=(pz*qz);cout<<"rz-=(pz*qz)= "<<rz<<endl;
rz-=(pz*qz)= 2790
rz*=(pz*qz-qz%pz);cout<<"rz*=(pz*qz-qz\%pz)= "<<rz<<endl;
rz*=(pz*qz-qz%pz)= 71315014444804620519472986292919523045963722675091300
//Big rationals
BQ pq("1000232325454545232322343421111111434343435555"),
qq(25555),rq;
cout<<"pq/=qq = "<<(pq/=qq)<<endl;
pq/=qq = 200046465090909046464468684222222286868687111/5111
rq=pq/qq+qq; cout<<"pq/qq+qq= "<<rq<<endl;
pq/qq+qq= 200046465090909046464468684222225624648252886/130611605
}