]> www.ginac.de Git - cln.git/blobdiff - examples/contfrac.cc
Retrieve the real time through gettimeofday(), not times().
[cln.git] / examples / contfrac.cc
index e716f050f2a664483b8777c939862568ce666f3e..8c3b0be075af228b8e2cd3b02cad31e2ea50c908 100644 (file)
 using namespace std;
 using namespace cln;
 
-// Our private error handling: return to the main program.
-#include <setjmp.h>
-jmp_buf restartpoint;
-namespace cln {
-       void cl_abort (void) { longjmp(restartpoint,1); }
-}
-
 int main (int argc, char* argv[])
 {
        for (int i = 1; i < argc; i++) {
                const char * arg = argv[i];
-               if (setjmp(restartpoint))
-                       continue;
-               // 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;
+               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& ) {}
        }
 }