7 #include "cln/integer.h"
18 const cl_I operator* (const cl_I& x, const cl_I& y)
21 // x=0 oder y=0 -> Ergebnis 0
22 // x und y beide Fixnums -> direkt multiplizieren
23 // sonst: zu DS machen, multiplizieren.
28 if (fixnump(x) && fixnump(y))
29 { var sintV x_ = FN_to_V(x);
30 var sintV y_ = FN_to_V(y);
31 #if (cl_value_len > 32)
32 // nur falls x und y Integers mit höchstens 32 Bit sind:
33 if (((uintV)((sintV)sign_of(x_) ^ x_) < bit(31))
34 && ((uintV)((sintV)sign_of(y_) ^ y_) < bit(31)))
37 // Werte direkt multiplizieren:
40 mulu32((uint32)x_,(uint32)y_,hi=,lo=); // erst unsigned multiplizieren
41 if (x_ < 0) { hi -= (uint32)y_; } // dann Korrektur für Vorzeichen
42 if (y_ < 0) { hi -= (uint32)x_; } // (vgl. DS_DS_mul_DS)
43 return L2_to_I(hi,lo);
47 var const uintD* xMSDptr;
49 var const uintD* xLSDptr;
50 var const uintD* yMSDptr;
52 var const uintD* yLSDptr;
55 I_to_NDS_nocopy(x, xMSDptr = , xlen = , xLSDptr = , false,);
56 I_to_NDS_nocopy(y, yMSDptr = , ylen = , yLSDptr = , false,);
57 DS_DS_mul_DS(xMSDptr,xlen,xLSDptr,yMSDptr,ylen,yLSDptr, ergMSDptr=,erglen=,);
58 return DS_to_I(ergMSDptr,erglen);
60 // Bit complexity (x,y of length N): O(M(N)).