/usr/share/doc/libcln-dev/examples/contfrac.cc is in libcln-dev 1.3.3-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | // Print the continued fraction of a real number.
// We work with real numbers and integers.
#include <cln/real.h>
#include <cln/integer.h>
// We do I/O.
#include <cln/io.h>
#include <cln/integer_io.h>
using namespace std;
using namespace cln;
int main (int argc, char* argv[])
{
for (int i = 1; i < argc; i++) {
const char * arg = argv[i];
try {
// Convert argument to its internal representation:
cl_R x = arg;
// Check sign.
if (minusp(x)) {
cout << '-';
x = -x;
}
cout << "[";
const char* separator = "; ";
for (;;) {
// Split x into integral and fractional part.
cl_R_div_t x_split = floor2(x);
cout << x_split.quotient;
x = x_split.remainder;
if (zerop(x))
break;
cout << separator;
separator = ", ";
// Invert x.
x = recip(x);
}
cout << ']' << endl;
} catch ( const runtime_exception& ) {}
}
}
|