2 * The following program was used to compute the first 100,000,000 decimal
3 * digits of e = exp(1), on December 18-20, 1998.
4 * Timings on a Sun UltraSparc-II (296 MHz), running Solaris 2.6, equipped
5 * with 512 MB RAM and 2 GB swap:
8 * computation of e: real time: 0.002 s, run time: 0.000 s
9 * conversion to decimal: real time: 0.003 s, run time: 0.000 s
11 * computation of e: real time: 0.018 s, run time: 0.020 s
12 * conversion to decimal: real time: 0.028 s, run time: 0.020 s
14 * computation of e: real time: 0.488 s, run time: 0.480 s
15 * conversion to decimal: real time: 1.059 s, run time: 1.060 s
17 * computation of e: real time: 8.139 s, run time: 8.010 s
18 * conversion to decimal: real time: 16.593 s, run time: 16.540 s
20 * computation of e: real time: 122.383 s, run time: 121.020 s
21 * conversion to decimal: real time: 252.524 s, run time: 250.760 s
23 * computation of e: real time: 2152.061 s, run time: 2056.430 s
24 * conversion to decimal: real time: 3579.670 s, run time: 3388.990 s
26 * computation of e: real time: 40061.367 s, run time: 30449.630 s
27 * conversion to decimal: real time: 54507.003 s, run time: 40063.510 s
30 #include <cln/number.h>
32 #include <cln/integer.h>
33 #include <cln/integer_io.h>
34 #include <cln/float.h>
35 #include <cln/float_io.h>
37 #include <cln/complex.h>
39 #include <cln/timing.h>
46 sum_exp1 (uintC a, uintC b, cl_I & first, cl_I & second)
55 cl_I s = (a + b) >> 1;
62 cl_I lp, lq, rp, rq, tmp;
63 uintC mid = (a + b) >> 1;
64 sum_exp1 (a, mid, lp, lq);
65 sum_exp1 (mid, b, rp, rq);
75 extern cl_LF cl_I_to_LF(const cl_I&, uintC);
79 const_exp1 (cl_LF & result, uintC dec)
81 uintC c = (uintC) (dec * ::log (10));
83 uintC actuallen = (uintC)(3.321928094 * dec / intDsize);
84 n = (uintC) ((n + c) / ::log ((double)n));
85 n = (uintC) ((n + c) / ::log ((double)n));
86 n = (uintC) ((n + c) / ::log ((double)n));
91 cout << "n = " << n << endl;
92 cout << "actuallen = " << actuallen << endl;
94 sum_exp1 (0, n, p, q);
95 cout << "sum_exp1 ends ok" << endl;
96 result = The(cl_LF)(cl_I_to_LF (p, actuallen) / cl_I_to_LF (q, actuallen));
97 cout << "const_exp1 returns ok" << endl;
101 main (int argc, char *argv[])
105 if (!strcmp(argv[1],"-n")) {
106 digits = atol(argv[2]);
107 argc -= 2; argv += 2;
117 cout << "\nCalculating exp1 to " << l << " decimals" << endl;