Browse Source

* Update a little.

master
Richard Kreckel 17 years ago
parent
commit
c8b1a99940
  1. 20
      examples/e.cc
  2. 2
      examples/fibonacci.cc
  3. 9
      examples/pi.cc

20
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;
}

2
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);

9
examples/pi.cc

@ -3,6 +3,7 @@
#include <cln/output.h>
#include <cln/real.h>
#include <cln/real_io.h>
#include <cln/version.h>
#include <cctype>
#include <cstdlib>
#include <cstring>
@ -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;
Loading…
Cancel
Save