From c8b1a99940b89737128414385a0a40044c077a7a Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Fri, 11 Jan 2008 17:16:15 +0000 Subject: [PATCH] * Update a little. --- examples/e.cc | 20 ++++++++++---------- examples/fibonacci.cc | 2 +- examples/pi.cc | 9 ++++++--- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/examples/e.cc b/examples/e.cc index e167576..9aa7c63 100644 --- a/examples/e.cc +++ b/examples/e.cc @@ -43,7 +43,7 @@ using namespace std; using namespace cln; void -sum_exp1 (uintL a, uintL b, cl_I & first, cl_I & second) +sum_exp1 (uintC a, uintC b, cl_I & first, cl_I & second) { switch (b - a) { @@ -60,7 +60,7 @@ sum_exp1 (uintL a, uintL b, cl_I & first, cl_I & second) default: { cl_I lp, lq, rp, rq, tmp; - uintL mid = (a + b) >> 1; + uintC mid = (a + b) >> 1; sum_exp1 (a, mid, lp, lq); sum_exp1 (mid, b, rp, rq); tmp = lp * rq; @@ -76,14 +76,14 @@ namespace cln { } void -const_exp1 (cl_LF & result, uintL dec) +const_exp1 (cl_LF & result, uintC dec) { - uintL c = (uintL) (dec * ::log (10)); - uintL n = dec; + uintC c = (uintC) (dec * ::log (10)); + uintC n = dec; uintC actuallen = (uintC)(3.321928094 * dec / intDsize); - n = (uintL) ((n + c) / ::log ((double)n)); - n = (uintL) ((n + c) / ::log ((double)n)); - n = (uintL) ((n + c) / ::log ((double)n)); + n = (uintC) ((n + c) / ::log ((double)n)); + n = (uintC) ((n + c) / ::log ((double)n)); + n = (uintC) ((n + c) / ::log ((double)n)); n += 2; actuallen += 2; @@ -100,10 +100,10 @@ const_exp1 (cl_LF & result, uintL dec) int main (int argc, char *argv[]) { - int digits = 100; + long digits = 100; while (argc >= 3) { if (!strcmp(argv[1],"-n")) { - digits = atoi(argv[2]); + digits = atol(argv[2]); argc -= 2; argv += 2; continue; } diff --git a/examples/fibonacci.cc b/examples/fibonacci.cc index df97512..57e014a 100644 --- a/examples/fibonacci.cc +++ b/examples/fibonacci.cc @@ -88,7 +88,7 @@ const cl_I fibonacci_compact (int n) cl_I u = 0; cl_I v = 1; cl_I m = n/2; // floor(n/2) - for (uintL bit=integer_length(m); bit>0; --bit) { + for (uintC bit=integer_length(m); bit>0; --bit) { // Since a squaring is cheaper than a multiplication, better use // three squarings instead of one multiplication and two squarings. cl_I u2 = square(u); diff --git a/examples/pi.cc b/examples/pi.cc index ce82bb8..d8b310f 100644 --- a/examples/pi.cc +++ b/examples/pi.cc @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -31,10 +32,12 @@ main (int argc, char * argv[]) return 0; } if (argc == 2 && !strcmp(argv[1],"--version")) { - cout << "pi (cln) " << CL_VERSION_MAJOR << "." << CL_VERSION_MINOR << endl; - cout << "Written by Bruno Haible." << endl; + cout << "pi (CLN " + << version_major << "." << version_minor << "." << version_patchlevel + << ")" << endl; + cout << "Written by Bruno Haible and Richard B. Kreckel." << endl; cout << endl; - cout << "Copyright (C) 1998-2008 Bruno Haible, 2000-2008 Richard B. Kreckel." << endl; + cout << "Copyright (C) 1988-2008 Bruno Haible, 2000-2008 Richard B. Kreckel." << endl; cout << "This is free software; see the source for copying conditions. There is NO" << endl; cout << "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." << endl; cout << endl;