1 // Public integer operations.
6 #include "cln/number.h"
7 #include "cln/integer_class.h"
8 #include "cln/random.h"
12 CL_DEFINE_AS_CONVERSION(cl_I)
15 // Konversion Integer >=0, <2^32 nach uintL.
16 // Wandelt Integer >=0 in Unsigned Longword um.
18 // > obj: Integer, sollte >=0, <2^32 sein
19 // < ergebnis: der Wert des Integer als 32-Bit-Zahl.
20 extern uint32 cl_I_to_UL (const cl_I& obj);
22 // Konversion Integer >=-2^31, <2^31 nach sintL.
23 // Wandelt Integer in Signed Longword um.
25 // > obj: Integer, sollte >=-2^31, <2^31 sein
26 // < ergebnis: der Wert des Integer als 32-Bit-Zahl.
27 extern sint32 cl_I_to_L (const cl_I& obj);
29 // Convert an integer to a C `int' or `unsigned int'.
31 inline int cl_I_to_int (const cl_I& x) { return cl_I_to_L(x); }
32 inline unsigned int cl_I_to_uint (const cl_I& x) { return cl_I_to_UL(x); }
35 // Convert an integer to a C `long' or `unsigned long'.
36 #if (long_bitsize==32)
37 inline long cl_I_to_long (const cl_I& x) { return cl_I_to_L(x); }
38 inline unsigned long cl_I_to_ulong (const cl_I& x) { return cl_I_to_UL(x); }
39 #elif (long_bitsize==64)
40 extern uint64 cl_I_to_UQ (const cl_I& obj);
41 extern sint64 cl_I_to_Q (const cl_I& obj);
42 inline long cl_I_to_long (const cl_I& x) { return cl_I_to_Q(x); }
43 inline unsigned long cl_I_to_ulong (const cl_I& x) { return cl_I_to_UQ(x); }
47 // Logische Operationen auf Integers:
49 // (LOGIOR x y), wenn x, y Integers sind.
51 extern const cl_I logior (const cl_I& x, const cl_I& y);
53 // (LOGXOR x y), wenn x, y Integers sind.
55 extern const cl_I logxor (const cl_I& x, const cl_I& y);
57 // (LOGAND x y), wenn x, y Integers sind.
59 extern const cl_I logand (const cl_I& x, const cl_I& y);
61 // (LOGEQV x y), wenn x, y Integers sind.
63 extern const cl_I logeqv (const cl_I& x, const cl_I& y);
65 // (LOGNAND x y), wenn x, y Integers sind.
67 extern const cl_I lognand (const cl_I& x, const cl_I& y);
69 // (LOGNOR x y), wenn x, y Integers sind.
71 extern const cl_I lognor (const cl_I& x, const cl_I& y);
73 // (LOGANDC2 x y), wenn x, y Integers sind.
75 extern const cl_I logandc2 (const cl_I& x, const cl_I& y);
77 // (LOGANDC1 x y), wenn x, y Integers sind.
79 inline const cl_I logandc1 (const cl_I& x, const cl_I& y)
84 // (LOGORC2 x y), wenn x, y Integers sind.
86 extern const cl_I logorc2 (const cl_I& x, const cl_I& y);
88 // (LOGORC1 x y), wenn x, y Integers sind.
90 inline const cl_I logorc1 (const cl_I& x, const cl_I& y)
95 // (LOGNOT x), wenn x ein Integer sind.
97 extern const cl_I lognot (const cl_I& x);
99 // Konstanten für BOOLE:
119 // (BOOLE op x y), wenn x und y Integers und op ein Objekt sind.
121 extern const cl_I boole (cl_boole op, const cl_I& x, const cl_I& y);
123 // Prüft, ob (LOGTEST x y), wo x und y Integers sind.
124 // (LOGTEST x y) = (NOT (ZEROP (LOGAND x y))).
125 // < ergebnis: /=0, falls ja; =0, falls nein.
126 extern cl_boolean logtest (const cl_I& x, const cl_I& y);
128 // Prüft, ob (LOGBITP x y), wo x und y Integers sind.
129 // Ergebnis: /=0, wenn ja; =0, wenn nein.
130 extern cl_boolean logbitp (uintC x, const cl_I& y);
131 extern cl_boolean logbitp (const cl_I& x, const cl_I& y);
133 // Prüft, ob (ODDP x), wo x ein Integer ist.
134 // Ergebnis: /=0, falls ja; =0, falls nein.
135 extern cl_boolean oddp (const cl_I& x);
137 // Prüft, ob (EVENP x), wo x ein Integer ist.
138 // Ergebnis: /=0, falls ja; =0, falls nein.
139 inline cl_boolean evenp (const cl_I& x)
140 { return (cl_boolean) (!oddp(x)); }
142 // (ASH x y), wo x und y Integers sind. Ergebnis Integer.
143 extern const cl_I ash (const cl_I& x, sintC y);
144 extern const cl_I ash (const cl_I& x, const cl_I& y);
146 // (LOGCOUNT x), wo x ein Integer ist. Ergebnis uintL.
147 extern uintC logcount (const cl_I& x);
149 // (INTEGER-LENGTH x), wo x ein Integer ist. Ergebnis uintL.
150 extern uintC integer_length (const cl_I& x);
152 // (ORD2 x) = max{n>=0: 2^n | x }, wo x ein Integer /=0 ist. Ergebnis uintL.
153 extern uintC ord2 (const cl_I& x);
155 // power2p(x) stellt fest, ob ein Integer x>0 eine Zweierpotenz ist.
156 // Ergebnis: n>0, wenn x=2^(n-1), 0 sonst.
157 extern uintC power2p (const cl_I& x);
159 inline const cl_I operator| (const cl_I& x, const cl_I& y)
160 { return logior(x,y); }
161 inline const cl_I operator^ (const cl_I& x, const cl_I& y)
162 { return logxor(x,y); }
163 inline const cl_I operator& (const cl_I& x, const cl_I& y)
164 { return logand(x,y); }
165 inline const cl_I operator~ (const cl_I& x)
166 { return lognot(x); }
167 #ifdef WANT_OBFUSCATING_OPERATORS
168 // This could be optimized to use in-place operations.
169 inline cl_I& operator|= (cl_I& x, const cl_I& y) { return x = x | y; }
170 inline cl_I& operator^= (cl_I& x, const cl_I& y) { return x = x ^ y; }
171 inline cl_I& operator&= (cl_I& x, const cl_I& y) { return x = x & y; }
175 // Addition/Subtraktion von Integers
177 // (1+ x), wo x ein Integer ist. Ergebnis Integer.
178 extern const cl_I plus1 (const cl_I& x);
180 // (1- x), wo x ein Integer ist. Ergebnis Integer.
181 extern const cl_I minus1 (const cl_I& x);
183 // (+ x y), wo x und y Integers sind. Ergebnis Integer.
184 extern const cl_I operator+ (const cl_I& x, const cl_I& y);
185 // Dem C++-Compiler muß man auch das Folgende sagen:
186 inline const cl_I operator+ (const int x, const cl_I& y)
187 { return cl_I(x) + y; }
188 inline const cl_I operator+ (const unsigned int x, const cl_I& y)
189 { return cl_I(x) + y; }
190 inline const cl_I operator+ (const long x, const cl_I& y)
191 { return cl_I(x) + y; }
192 inline const cl_I operator+ (const unsigned long x, const cl_I& y)
193 { return cl_I(x) + y; }
194 inline const cl_I operator+ (const cl_I& x, const int y)
195 { return x + cl_I(y); }
196 inline const cl_I operator+ (const cl_I& x, const unsigned int y)
197 { return x + cl_I(y); }
198 inline const cl_I operator+ (const cl_I& x, const long y)
199 { return x + cl_I(y); }
200 inline const cl_I operator+ (const cl_I& x, const unsigned long y)
201 { return x + cl_I(y); }
203 // (- x), wenn x ein Integer ist. Ergebnis Integer.
204 extern const cl_I operator- (const cl_I& x);
206 // (- x y), wo x und y Integers sind. Ergebnis Integer.
207 extern const cl_I operator- (const cl_I& x, const cl_I& y);
208 // Dem C++-Compiler muß man auch das Folgende sagen:
209 inline const cl_I operator- (const int x, const cl_I& y)
210 { return cl_I(x) - y; }
211 inline const cl_I operator- (const unsigned int x, const cl_I& y)
212 { return cl_I(x) - y; }
213 inline const cl_I operator- (const long x, const cl_I& y)
214 { return cl_I(x) - y; }
215 inline const cl_I operator- (const unsigned long x, const cl_I& y)
216 { return cl_I(x) - y; }
217 inline const cl_I operator- (const cl_I& x, const int y)
218 { return x - cl_I(y); }
219 inline const cl_I operator- (const cl_I& x, const unsigned int y)
220 { return x - cl_I(y); }
221 inline const cl_I operator- (const cl_I& x, const long y)
222 { return x - cl_I(y); }
223 inline const cl_I operator- (const cl_I& x, const unsigned long y)
224 { return x - cl_I(y); }
226 // (abs x), wenn x ein Integer ist. Ergebnis Integer.
227 extern const cl_I abs (const cl_I& x);
230 inline const cl_I operator<< (const cl_I& x, sintC y) // assume 0 <= y < 2^(intCsize-1)
232 inline const cl_I operator<< (const cl_I& x, const cl_I& y) // assume y >= 0
234 inline const cl_I operator>> (const cl_I& x, sintC y) // assume 0 <= y < 2^(intCsize-1)
235 { return ash(x,-y); }
236 inline const cl_I operator>> (const cl_I& x, const cl_I& y) // assume y >= 0
237 { return ash(x,-y); }
240 // Vergleich von Integers
242 // equal(x,y) vergleicht zwei Integers x und y auf Gleichheit.
243 extern cl_boolean equal (const cl_I& x, const cl_I& y);
244 // equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
245 extern uint32 equal_hashcode (const cl_I& x);
247 // compare(x,y) vergleicht zwei Integers x und y.
248 // Ergebnis: 0 falls x=y, +1 falls x>y, -1 falls x<y.
249 extern cl_signean compare (const cl_I& x, const cl_I& y);
251 inline bool operator== (const cl_I& x, const cl_I& y)
252 { return equal(x,y); }
253 inline bool operator!= (const cl_I& x, const cl_I& y)
254 { return !equal(x,y); }
255 inline bool operator<= (const cl_I& x, const cl_I& y)
256 { return compare(x,y)<=0; }
257 inline bool operator< (const cl_I& x, const cl_I& y)
258 { return compare(x,y)<0; }
259 inline bool operator>= (const cl_I& x, const cl_I& y)
260 { return compare(x,y)>=0; }
261 inline bool operator> (const cl_I& x, const cl_I& y)
262 { return compare(x,y)>0; }
264 // minusp(x) == (< x 0)
265 extern cl_boolean minusp (const cl_I& x);
267 // plusp(x) == (> x 0)
268 extern cl_boolean plusp (const cl_I& x);
270 // zerop(x) stellt fest, ob ein Integer = 0 ist.
271 extern cl_boolean zerop (const cl_I& x);
274 // BYTE-Operationen auf Integers
280 cl_byte (uintC s, uintC p) : size (s), position (p) {}
283 // (LDB byte n), wo n ein Integer ist.
284 extern const cl_I ldb (const cl_I& n, const cl_byte& b);
286 // ldb_test(n,byte) führt (LDB-TEST byte n) aus, wobei n ein Integer ist.
287 // Ergebnis: cl_false wenn nein (also alle fraglichen Bits =0), cl_true wenn ja.
288 extern cl_boolean ldb_test (const cl_I& n, const cl_byte& b);
290 // (MASK-FIELD byte n), wo n ein Integer ist.
291 extern const cl_I mask_field (const cl_I& n, const cl_byte& b);
293 // (DEPOSIT-FIELD newbyte byte n), wo n und newbyte Integers sind.
294 extern const cl_I deposit_field (const cl_I& newbyte, const cl_I& n, const cl_byte& b);
296 // (DPB newbyte byte n), wo n und newbyte Integers sind.
297 extern const cl_I dpb (const cl_I& newbyte, const cl_I& n, const cl_byte& b);
300 // Multiplikation ganzer Zahlen
302 // (* x y), wo x und y Integers sind. Ergebnis Integer.
303 extern const cl_I operator* (const cl_I& x, const cl_I& y);
304 // Dem C++-Compiler muß man auch das Folgende sagen:
305 inline const cl_I operator* (const int x, const cl_I& y)
306 { return cl_I(x) * y; }
307 inline const cl_I operator* (const unsigned int x, const cl_I& y)
308 { return cl_I(x) * y; }
309 inline const cl_I operator* (const long x, const cl_I& y)
310 { return cl_I(x) * y; }
311 inline const cl_I operator* (const unsigned long x, const cl_I& y)
312 { return cl_I(x) * y; }
313 inline const cl_I operator* (const cl_I& x, const int y)
314 { return x * cl_I(y); }
315 inline const cl_I operator* (const cl_I& x, const unsigned int y)
316 { return x * cl_I(y); }
317 inline const cl_I operator* (const cl_I& x, const long y)
318 { return x * cl_I(y); }
319 inline const cl_I operator* (const cl_I& x, const unsigned long y)
320 { return x * cl_I(y); }
322 // (EXPT x 2), wo x Integer ist.
323 extern const cl_I square (const cl_I& x);
325 // (EXPT x y), wo x Integer, y Integer >0 ist.
326 extern const cl_I expt_pos (const cl_I& x, uintL y);
327 extern const cl_I expt_pos (const cl_I& x, const cl_I& y);
329 // Fakultät (! n), wo n Fixnum >=0 ist. Ergebnis Integer.
330 extern const cl_I factorial (uintL n);
331 //CL_REQUIRE(cl_I_factorial)
333 // Double factorial (!! n), with n Fixnum >=0. Returns integer.
334 extern const cl_I doublefactorial (uintL n);
336 // Binomialkoeffizient (n \choose k) = n! / k! (n-k)!, wo n,k >= 0 sind.
337 extern const cl_I binomial (uintL n, uintL k);
340 // Division ganzer Zahlen
342 // Return type for division operators.
343 // x / y --> (q,r) with x = y*q+r.
349 cl_I_div_t (const cl_I& q, const cl_I& r) : quotient(q), remainder(r) {}
352 // Dividiert zwei Integers x,y >=0 und liefert den Quotienten x/y >=0.
353 // Bei y=0 Error. Die Division muß aufgehen, sonst Error.
355 // > x,y: Integers >=0
356 // < ergebnis: Quotient x/y, ein Integer >=0
357 extern const cl_I exquopos (const cl_I& x, const cl_I& y);
359 // Dividiert zwei Integers x,y und liefert den Quotienten x/y.
360 // Bei y=0 Error. Die Division muß aufgehen, sonst Error.
363 // < ergebnis: Quotient x/y, ein Integer
364 extern const cl_I exquo (const cl_I& x, const cl_I& y);
366 // mod(x,y) = (mod x y), wo x,y Integers sind.
367 extern const cl_I mod (const cl_I& x, const cl_I& y);
369 // rem(x,y) = (rem x y), wo x,y Integers sind.
370 extern const cl_I rem (const cl_I& x, const cl_I& y);
372 // Dividiert zwei Integers x,y und liefert Quotient und Rest
373 // (q,r) := (floor x y)
376 // < q,r: Quotient q, Rest r
377 extern const cl_I_div_t floor2 (const cl_I& x, const cl_I& y);
378 extern const cl_I floor1 (const cl_I& x, const cl_I& y);
380 // Dividiert zwei Integers x,y und liefert Quotient und Rest
381 // (q,r) := (ceiling x y)
384 // < q,r: Quotient q, Rest r
385 extern const cl_I_div_t ceiling2 (const cl_I& x, const cl_I& y);
386 extern const cl_I ceiling1 (const cl_I& x, const cl_I& y);
388 // Dividiert zwei Integers x,y und liefert Quotient und Rest
389 // (q,r) := (truncate x y)
392 // < q,r: Quotient q, Rest r
393 extern const cl_I_div_t truncate2 (const cl_I& x, const cl_I& y);
394 extern const cl_I truncate1 (const cl_I& x, const cl_I& y);
396 // Dividiert zwei Integers x,y und liefert Quotient und Rest
397 // (q,r) := (round x y)
400 // < q,r: Quotient q, Rest r
401 extern const cl_I_div_t round2 (const cl_I& x, const cl_I& y);
402 extern const cl_I round1 (const cl_I& x, const cl_I& y);
405 // ggT und kgV von Integers
407 // Liefert den ggT zweier Integers.
409 // > a,b: zwei Integers
410 // < ergebnis: (gcd a b), ein Integer >=0
411 extern const cl_I gcd (const cl_I& a, const cl_I& b);
412 extern uintV gcd (uintV a, uintV b);
414 // Liefert den ggT zweier Integers samt Beifaktoren.
415 // g = xgcd(a,b,&u,&v)
416 // > a,b: zwei Integers
417 // < u, v, g: Integers mit u*a+v*b = g >= 0
418 extern const cl_I xgcd (const cl_I& a, const cl_I& b, cl_I* u, cl_I* v);
419 // Im Fall A/=0, B/=0 genügt das Ergebnis (g,u,v) den Ungleichungen:
420 // Falls |A| = |B| : g = |A|, u = (signum A), v = 0.
421 // Falls |B| | |A|, |B| < |A| : g = |B|, u = 0, v = (signum B).
422 // Falls |A| | |B|, |A| < |B| : g = |A|, u = (signum A), v = 0.
423 // Sonst: |u| <= |B| / (2*g), |v| <= |A| / (2*g).
424 // In jedem Fall |u| <= |B|/g, |v| < |A|/g.
425 // (Beweis: Im Prinzip macht man ja mehrere Euklid-Schritte auf einmal. Im
426 // letzten Fall - oBdA |A| > |B| - braucht man mindestens zwei Euklid-Schritte,
427 // also gilt im Euklid-Tableau
429 // --------------------------------------------
433 // n-1 -(-1)^n*x[n-1] (-1)^n*y[n-1] z[n-1]
434 // n (-1)^n*x[n] -(-1)^n*y[n] z[n]
435 // n+1 -(-1)^n*x[n+1] (-1)^n*y[n+1] z[n+1] = 0
436 // --------------------------------------------
437 // g = z[n], |u|=x[n], |v|=y[n]
438 // n>=2, z[0] > ... > z[n-1] > z[n] = g, g | z[n-1], also z[n-1] >= 2*g.
439 // Da aber mit (-1)^i*x[i]*|A| - (-1)^i*y[i]*|B| = z[i] für i=0..n+1
440 // und x[i]*y[i+1] - x[i+1]*y[i] = (-1)^i für i=0..n,
441 // x[i]*z[i+1] - x[i+1]*z[i] = (-1)^i*|B| für i=0..n,
442 // y[i]*z[i+1] - y[i+1]*z[i] = -(-1)^i*|A| für i=0..n
443 // auch |A| = y[i+1]*z[i] + y[i]*z[i+1], |B| = x[i+1]*z[i] + x[i]*z[i+1]
444 // für i=0..n (Cramersche Regel), folgt
445 // |A| = y[n]*z[n-1] + y[n-1]*z[n] >= y[n]*2*g + 0 = |v|*2*g,
446 // |B| = x[n]*z[n-1] + x[n-1]*z[n] >= x[n]*2*g + 0 = |u|*2*g.)
448 // Liefert den kgV zweier Integers.
450 // > a,b: zwei Integers
451 // < ergebnis: (lcm a b), ein Integer >=0
452 extern const cl_I lcm (const cl_I& a, const cl_I& b);
455 // Wurzel aus ganzen Zahlen
457 // Zieht die Wurzel (ISQRT x) aus einem Integer.
459 // > x: Integer (sollte >=0 sein)
461 // < ergebnis: cl_true falls x Quadratzahl, cl_false sonst
462 extern cl_boolean isqrt (const cl_I& x, cl_I* w);
463 // Wenn das boolesche Ergebnis uninteressant ist:
464 inline const cl_I isqrt (const cl_I& x) { cl_I w; isqrt(x,&w); return w; }
466 // Stellt fest, ob ein Integer >=0 eine Quadratzahl ist.
468 // > x: ein Integer >=0
469 // < w: Integer (sqrt x) falls x Quadratzahl
470 // < ergebnis: cl_true ..................., cl_false sonst
471 extern cl_boolean sqrtp (const cl_I& x, cl_I* w);
473 // Stellt fest, ob ein Integer >=0 eine n-te Potenz ist.
475 // > x: ein Integer >=0
476 // > n: ein Integer >0
477 // < w: Integer (expt x (/ n)) falls x eine n-te Potenz
478 // < ergebnis: cl_true ........................, cl_false sonst
479 extern cl_boolean rootp (const cl_I& x, uintL n, cl_I* w);
480 extern cl_boolean rootp (const cl_I& x, const cl_I& n, cl_I* w);
483 // max(x,y) liefert (max x y), wo x und y ganze Zahlen sind.
484 extern const cl_I max (const cl_I& x, const cl_I& y);
486 // min(x,y) liefert (min x y), wo x und y ganze Zahlen sind.
487 extern const cl_I min (const cl_I& x, const cl_I& y);
489 // signum(x) liefert (signum x), wo x eine ganze Zahl ist.
490 extern const cl_I signum (const cl_I& x);
493 // Multipliziert ein Integer mit 10 und addiert eine weitere Ziffer.
494 // mul_10_plus_x(y,x)
495 // > y: Integer Y (>=0)
496 // > x: Ziffernwert X (>=0,<10)
497 // < ergebnis: Integer Y*10+X (>=0)
498 extern const cl_I mul_10_plus_x (const cl_I& y, unsigned char x);
501 // 2-adische Inverse.
502 // cl_recip2adic(n,x)
504 // > x: Integer, ungerade
505 // < ergebnis: n-Bit-Zahl y == (x mod 2^n)^-1, d.h. y*x == 1 mod 2^n
506 extern const cl_I cl_recip2adic (uintL n, const cl_I& x);
508 // 2-adische Division.
509 // cl_div2adic(n,x,y)
512 // > y: Integer, ungerade
513 // < ergebnis: n-Bit-Zahl z == (x mod 2^n)/(y mod 2^n), d.h. z*y == x mod 2^n
514 extern const cl_I cl_div2adic (uintL n, const cl_I& x, const cl_I& y);
517 // numerator(r) liefert den Zähler des Integer r.
518 inline const cl_I numerator (const cl_I& r)
520 // denominator(r) liefert den Nenner (> 0) des Integer r.
521 inline const cl_I denominator (const cl_I& r)
522 { (void)r; return 1; }
525 // Konversion zu einem C "float".
526 extern float float_approx (const cl_I& x);
528 // Konversion zu einem C "double".
529 extern double double_approx (const cl_I& x);
532 // random_I(randomstate,n) liefert zu einem Integer n>0 ein zufälliges
533 // Integer x mit 0 <= x < n.
534 // > randomstate: ein Random-State, wird verändert
535 extern const cl_I random_I (random_state& randomstate, const cl_I& n);
537 inline const cl_I random_I (const cl_I& n)
538 { return random_I(default_random_state,n); }
540 // testrandom_I(randomstate) liefert ein zufälliges Integer zum Testen.
541 // > randomstate: ein Random-State, wird verändert
542 extern const cl_I testrandom_I (random_state& randomstate);
544 inline const cl_I testrandom_I ()
545 { return testrandom_I(default_random_state); }
548 #ifdef WANT_OBFUSCATING_OPERATORS
549 // This could be optimized to use in-place operations.
550 inline cl_I& operator+= (cl_I& x, const cl_I& y) { return x = x + y; }
551 inline cl_I& operator+= (cl_I& x, const int y) { return x = x + y; }
552 inline cl_I& operator+= (cl_I& x, const unsigned int y) { return x = x + y; }
553 inline cl_I& operator+= (cl_I& x, const long y) { return x = x + y; }
554 inline cl_I& operator+= (cl_I& x, const unsigned long y) { return x = x + y; }
555 inline cl_I& operator++ /* prefix */ (cl_I& x) { return x = plus1(x); }
556 inline void operator++ /* postfix */ (cl_I& x, int dummy) { (void)dummy; x = plus1(x); }
557 inline cl_I& operator-= (cl_I& x, const cl_I& y) { return x = x - y; }
558 inline cl_I& operator-= (cl_I& x, const int y) { return x = x - y; }
559 inline cl_I& operator-= (cl_I& x, const unsigned int y) { return x = x - y; }
560 inline cl_I& operator-= (cl_I& x, const long y) { return x = x - y; }
561 inline cl_I& operator-= (cl_I& x, const unsigned long y) { return x = x - y; }
562 inline cl_I& operator-- /* prefix */ (cl_I& x) { return x = minus1(x); }
563 inline void operator-- /* postfix */ (cl_I& x, int dummy) { (void)dummy; x = minus1(x); }
564 inline cl_I& operator*= (cl_I& x, const cl_I& y) { return x = x * y; }
565 inline cl_I& operator<<= (cl_I& x, sintC y) // assume 0 <= y < 2^(intCsize-1)
566 { return x = x << y; }
567 inline cl_I& operator<<= (cl_I& x, const cl_I& y) // assume y >= 0
568 { return x = x << y; }
569 inline cl_I& operator>>= (cl_I& x, sintC y) // assume 0 <= y < 2^(intCsize-1)
570 { return x = x >> y; }
571 inline cl_I& operator>>= (cl_I& x, const cl_I& y) // assume y >= 0
572 { return x = x >> y; }
573 #if 0 // Defining operator/ collides with the operator/ (cl_RA, cl_RA).
574 // operator/ should perform exquo(x,y), but people believe in the C semantics.
575 // And it would be wiser to use floor1 and mod instead of truncate1 and rem,
576 // but again, many C compilers implement / and % like this and people believe
578 inline const cl_I operator/ (const cl_I& x, const cl_I& y) { return truncate1(x,y); }
579 inline const cl_I operator% (const cl_I& x, const cl_I& y) { return rem(x,y); }
580 inline cl_I& operator/= (cl_I& x, const cl_I& y) { return x = x / y; }
581 inline cl_I& operator%= (cl_I& x, const cl_I& y) { return x = x % y; }
586 // Runtime typing support.
587 extern cl_class cl_class_fixnum;
588 extern cl_class cl_class_bignum;
589 CL_FORCE_LINK(cl_I_classes_dummy, cl_class_fixnum)
592 // Debugging support.
594 extern int cl_I_debug_module;
595 CL_FORCE_LINK(cl_I_debug_dummy, cl_I_debug_module)
600 #endif /* _CL_INTEGER_H */