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 sint32 x_ = FN_to_L(x);
30 var sint32 y_ = FN_to_L(y);
31 // Werte direkt multiplizieren:
34 mulu32((uint32)x_,(uint32)y_,hi=,lo=); // erst unsigned multiplizieren
35 if (x_ < 0) { hi -= (uint32)y_; } // dann Korrektur für Vorzeichen
36 if (y_ < 0) { hi -= (uint32)x_; } // (vgl. DS_DS_mul_DS)
37 return L2_to_I(hi,lo);
40 var const uintD* xMSDptr;
42 var const uintD* xLSDptr;
43 var const uintD* yMSDptr;
45 var const uintD* yLSDptr;
48 I_to_NDS_nocopy(x, xMSDptr = , xlen = , xLSDptr = , cl_false,);
49 I_to_NDS_nocopy(y, yMSDptr = , ylen = , yLSDptr = , cl_false,);
50 DS_DS_mul_DS(xMSDptr,xlen,xLSDptr,yMSDptr,ylen,yLSDptr, ergMSDptr=,erglen=,);
51 return DS_to_I(ergMSDptr,erglen);
53 // Bit complexity (x,y of length N): O(M(N)).