]> www.ginac.de Git - cln.git/blobdiff - src/integer/bitwise/cl_I_ash.cc
Finalize CLN 1.3.7 release.
[cln.git] / src / integer / bitwise / cl_I_ash.cc
index bde719bf8cd50b623f53ffa1c141a51ba6046511..ddaa57008686d513484943e3921c03314dfc68ed 100644 (file)
@@ -1,7 +1,7 @@
 // ash().
 
 // General includes.
-#include "cl_sysdep.h"
+#include "base/cl_sysdep.h"
 
 // Specification.
 #include "cln/integer.h"
@@ -9,23 +9,22 @@
 
 // Implementation.
 
-#include "cl_I.h"
-#include "cl_DS.h"
-#include "cl_I_ash.h"
+#include "integer/cl_I.h"
+#include "base/digitseq/cl_DS.h"
 
 namespace cln {
 
-const cl_I ash (const cl_I& x, sintL y)
+const cl_I ash (const cl_I& x, sintC y)
 {
     // Methode:
     // x = 0 -> 0 als Ergebnis
     // y = 0 -> x als Ergebnis
     // y > 0 -> y = intDsize*k + i, j=k+(1 falls i>0, 0 falls i=0).
-    //          j Wörter mehr reservieren, k Nullwörter, dann übertragen,
+    //          j Wörter mehr reservieren, k Nullwörter, dann übertragen,
     //          bei i>0: um i Bits links schieben (i=1 geht einfacher).
-    // y < 0 -> y <= - intDsize * (Länge(A0) in Digits) -> Ergebnis = 0 oder -1.
-    //          Sonst: -y = intDsize*k + i mit k<Länge(A0).
-    //                  Übertrage die (Länge(A0)-k) MSDigits,
+    // y < 0 -> y <= - intDsize * (Länge(A0) in Digits) -> Ergebnis = 0 oder -1.
+    //          Sonst: -y = intDsize*k + i mit k<Länge(A0).
+    //                  Übertrage die (Länge(A0)-k) MSDigits,
     //                  falls i>0: schiebe sie um i Bits nach rechts (i=1 geht einfacher).
        if (zerop(x))
                return 0;               // x=0 -> 0 als Ergebnis
@@ -34,15 +33,15 @@ const cl_I ash (const cl_I& x, sintL y)
        CL_ALLOCA_STACK;
        if (y >= 0) {
                // y>0
-               var uintL y_ = (uintL)y;
+               var uintC y_ = (uintC)y;
                var uintL i = y_%intDsize; // i = y mod intDsize, >=0, <intDsize
-               var uintL k = floor(y_,intDsize); // k = y div intDsize, >=0, <2^intCsize
+               var uintC k = floor(y_,intDsize); // k = y div intDsize, >=0, <2^intCsize
                var uintD* LSDptr;
                var uintC len;
                var const uintD* x_LSDptr;
-               I_to_NDS_nocopy(x, ,len=,x_LSDptr=,cl_false,); // DS zu x bilden.
-               if (k >= (uintC)(~(uintC)len)) // kann len+k+1 Überlauf geben?
-                       { cl_ash_error(y); } // ja -> Fehler
+               I_to_NDS_nocopy(x, ,len=,x_LSDptr=,false,); // DS zu x bilden.
+               if (k >= (uintC)(~len)) // kann len+k+1 Überlauf geben?
+                       { throw ash_exception(y); } // ja -> Fehler
                num_stack_alloc_1(len+k,,LSDptr=);
                LSDptr = clear_loop_lsp(LSDptr,k); // k Nulldigits
               {var uintD* MSDptr = copy_loop_lsp(x_LSDptr,LSDptr,len);
@@ -66,14 +65,14 @@ const cl_I ash (const cl_I& x, sintL y)
               }
        } else {
                // y<0
-               var uintL y_ = (uintL)(-y); // Wert von -y, >0
+               var uintC y_ = (uintC)(-y); // Wert von -y, >0
                var uintL i = y_%intDsize; // i = (-y) mod intDsize, >=0, <intDsize
-               var uintL k = floor(y_,intDsize); // k = (-y) div intDsize, >=0
+               var uintC k = floor(y_,intDsize); // k = (-y) div intDsize, >=0
                // DS zu x bilden:
                var uintD* MSDptr;
                var uintC len;
                I_to_NDS(x, MSDptr=,len=,); // DS zu x bilden.
-               if (k>=len) goto sign; // -y >= intDsize*len -> Vorzeichen von x zurück
+               if (k>=len) goto sign; // -y >= intDsize*len -> Vorzeichen von x zurück
                len -= k; // rechte k Digits einfach streichen
                // Noch ist len>0. Um i Bits nach rechts schieben:
                if (!(i==0)) // Bei i>0: