7 #include "cl_integer.h"
16 // Logische Operationen auf Integers:
17 // Methode: aus den Längen der beiden Argumente eine obere Schranke für
18 // die Länge des Ergebnisses berechnen (das Maximum der beiden Längen und
19 // FN_maxlength), so daß das MSD für unendlich viele Bits steht.
20 // Dann beide Argumente in gleichgroße Digit sequences umwandeln, Operation
21 // mit einer einfachen Schleife durchführen.
23 const cl_I lognand (const cl_I& x, const cl_I& y)
24 { if (fixnump(x) && fixnump(y)) // Beides Fixnums -> ganz einfach:
25 { // bitweise als Fixnum zurück
26 return cl_I_from_word((x.word & y.word) ^ cl_combine(0,~(cl_uint)0));
29 { DeclareType(cl_FN,x);
31 // PosFixnum AND Bignum -> PosFixnum
32 { return cl_I_from_word((x.word & cl_combine(0,pFN_maxlength_digits_at(BN_LSDptr(y)))) ^ cl_combine(cl_FN_tag,~(cl_uint)0)); }
35 { DeclareType(cl_FN,y);
37 // Bignum AND PosFixnum -> PosFixnum
38 { return cl_I_from_word((cl_combine(0,pFN_maxlength_digits_at(BN_LSDptr(x))) & y.word) ^ cl_combine(cl_FN_tag,~(cl_uint)0)); }
41 var uintC n; // Anzahl der Digits
42 {var uintC nx = I_to_DS_need(x);
43 var uintC ny = I_to_DS_need(y);
44 n = (nx>=ny ? nx : ny);
46 {var uintD* xptr; I_to_DS_n(x,n,xptr=); // Pointer in DS zu x
47 var uintD* yptr; I_to_DS_n(y,n,yptr=); // Pointer in DS zu y
48 var uintD* zptr = xptr; // Pointer aufs Ergebnis
49 nand_loop_msp(xptr,yptr,n); // mit NOT AND verknüpfen
50 return DS_to_I(zptr,n); // Ergebnis als Integer