/* bench.cpp -- Matt Mahoney, mmahoney@cs.fit.edu This program is a benchmark for Integer and Real. It computes pi by two different methods at increasingly higher precisions and compares the results. Normally all but the last few digits will match due to roundoff errors in the calculations. The calculations are deliberately inefficient to test all the operators. It accepts one argument indicating the number of comparisons to be done (default 10). After each comparison it prints the average of the two values of pi (3.1415926535897...), the number of matching decimal digits, and the total run time so far. For UNIX, it is recommended that the time command be used to allow for CPU time used by other processes. The program assumes the unlimited range and precision numeric classes Integer and Real as described at http://cs.fit.edu/~mmahoney/cse2050 are available in two files in the current directory. mmahoney.h -- Class declarations and inlined code mmahoney.cpp -- Function definitions To compile: g++ bench.cpp mmahoney.cpp To run, e.g.: time a.out 10 */ #include "mmahoney.h" // Replace this with your header file #include #include #include #include using namespace std; // Absolute value Real abs(const Real& a) { if (a= 0 Integer factorial(const Integer& a) { Integer r=1; for (Integer i=1; i<=a; i+=1) r*=i; return r; } // Exponentiation, b >= 0, template T pow(const T& a, const Integer& b) { T r=1; for (Integer i=0; i1 ? atoi(argv[1]) : 10; int prec=16; for (int i=0; i