]> www.ginac.de Git - cln.git/blobdiff - src/integer/algebraic/cl_I_sqrt.cc
Finalize CLN 1.3.7 release.
[cln.git] / src / integer / algebraic / cl_I_sqrt.cc
index d59ba68e42831eadd44006293b8078de6a4e49e3..53575106032452e3fa21343e180f0379a4c334c8 100644 (file)
@@ -1,7 +1,7 @@
 // isqrt().
 
 // General includes.
-#include "cl_sysdep.h"
+#include "base/cl_sysdep.h"
 
 // Specification.
 #include "cln/integer.h"
 #include "cln/number.h"
 #include "cln/io.h"
 #include "cln/integer_io.h"
-#include "cln/abort.h"
-#include "cl_I.h"
-#include "cl_DS.h"
+#include "cln/exception.h"
+#include "integer/cl_I.h"
+#include "base/digitseq/cl_DS.h"
+#include <sstream>
 
 namespace cln {
 
-cl_boolean isqrt (const cl_I& x, cl_I* w)
+bool isqrt (const cl_I& x, cl_I* w)
 {
        if (minusp(x)) {
-               fprint(stderr, "isqrt: applied to negative number: ");
-               fprint(stderr, x);
-               fprint(stderr, "\n");
-               cl_abort();
+               std::ostringstream buf;
+               fprint(buf, "isqrt: applied to negative number: ");
+               fprint(buf, x);
+               throw runtime_exception(buf.str());
        }
        CL_ALLOCA_STACK;
        var const uintD* x_MSDptr;
        var uintC x_len;
        var const uintD* x_LSDptr;
-       I_to_NDS_nocopy(x, x_MSDptr=,x_len=,x_LSDptr=,cl_true,); // Digit sequence >=0 zu x
+       I_to_NDS_nocopy(x, x_MSDptr=,x_len=,x_LSDptr=,true,); // Digit sequence >=0 zu x
        var DS y;
-       var cl_boolean squarep;
+       var bool squarep;
        UDS_sqrt(x_MSDptr,x_len,x_LSDptr, &y, squarep=); // Wurzel ziehen
        *w = NUDS_to_I(y.MSDptr,y.len); // als Integer
        return squarep;