]> www.ginac.de Git - cln.git/blobdiff - src/integer/bitwise/cl_I_logbitp_I.cc
* */*: Remove cl_boolean, cl_true, and cl_false in favor of built-in
[cln.git] / src / integer / bitwise / cl_I_logbitp_I.cc
index 7dc76a09da4475795e9af609d34d496e773be8ff..03e885649d1b1d83b429cd6981098718fea222a8 100644 (file)
 #include "cl_DS.h"
 #include "cln/io.h"
 #include "cln/integer_io.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
+#include <sstream>
 
 namespace cln {
 
-cl_boolean logbitp (const cl_I& x, const cl_I& y)
+bool logbitp (const cl_I& x, const cl_I& y)
 {
     // Methode:
     // Falls x<0, Error.
@@ -25,29 +26,29 @@ cl_boolean logbitp (const cl_I& x, const cl_I& y)
     //             Sonst x=intDsize*k+i, Teste Bit i vom Worte Nr. k+1 (von oben herab).
       if (!minusp(x)) // x>=0 ?
         { if (fixnump(x))
-            { var uintL x_ = FN_to_L(x);
+            { var uintV x_ = FN_to_V(x);
               var uintC ylen;
               var const uintD* yLSDptr;
-              I_to_NDS_nocopy(y, ,ylen=,yLSDptr=,cl_true, { return cl_false; } ); // DS zu y
-              if (x_ < intDsize*(uintL)ylen)
+              I_to_NDS_nocopy(y, ,ylen=,yLSDptr=,true, { return false; } ); // DS zu y
+              if (x_ < intDsize*ylen)
                 // x ist ein Fixnum >=0, < intDsize*ylen
                 { if (lspref(yLSDptr,floor(x_,intDsize)) & bit(x_%intDsize))
-                    return cl_true;
+                    return true;
                     else
-                    return cl_false;
+                    return false;
             }   }
           // Vorzeichen von y testen
           if (minusp(y))
-            return cl_true;
+            return true;
             else
-            return cl_false;
+            return false;
         }
         else
         // x<0
-        { fprint(std::cerr, "logbitp: Index is negative: ");
-          fprint(std::cerr, x);
-          fprint(std::cerr, "\n");
-          cl_abort();
+        { std::ostringstream buf;
+          fprint(buf, "logbitp: Index is negative: ");
+          fprint(buf, x);
+          throw runtime_exception(buf.str());
         }
 }