4 #include "base/cl_sysdep.h"
7 #include "integer/cl_I.h"
12 #include "cln/number.h"
14 #if (cl_word_size < 64)
16 #include "base/digitseq/cl_DS.h"
20 cl_private_thing cl_I_constructor_from_L2 (sint32 wert_hi, uint32 wert_lo)
23 if ((wert_lo & minus_bit(cl_value_len-1)) == 0)
24 return (cl_private_thing)(cl_combine(cl_FN_tag,wert_lo));
26 elif (wert_hi == ~(sint32)0) {
27 if ((~wert_lo & minus_bit(cl_value_len-1)) == 0)
28 return (cl_private_thing)(cl_combine(cl_FN_tag,(sint32)wert_lo));
31 // (dessen Länge bn_minlength <= n <= ceiling(64/intDsize) erfüllt)
32 #define FILL_1_DIGIT(l,i,from) \
33 arrayLSref(ptr->data,l,i) = (uintD)from;
34 #define FILL_2_DIGIT(l,i,from) \
35 arrayLSref(ptr->data,l,i) = (uintD)from; \
36 arrayLSref(ptr->data,l,i+1) = (uintD)(from>>intDsize);
37 #define FILL_3_DIGIT(l,i,from) \
38 arrayLSref(ptr->data,l,i) = (uintD)from; from>>=intDsize; \
39 arrayLSref(ptr->data,l,i+1) = (uintD)from; \
40 arrayLSref(ptr->data,l,i+2) = (uintD)(from>>intDsize);
41 #define FILL_4_DIGIT(l,i,from) \
42 arrayLSref(ptr->data,l,i) = (uintD)from; from>>=intDsize; \
43 arrayLSref(ptr->data,l,i+1) = (uintD)from; from>>=intDsize; \
44 arrayLSref(ptr->data,l,i+2) = (uintD)from; \
45 arrayLSref(ptr->data,l,i+3) = (uintD)(from>>intDsize);
47 #define FILL_1 FILL_1_DIGIT(1,0,highlow64(wert_hi,wert_lo));
50 #define FILL_1 FILL_1_DIGIT(1,0,wert_lo);
51 #define FILL_2 FILL_1_DIGIT(2,1,wert_hi); FILL_1_DIGIT(2,0,wert_lo);
54 #define FILL_1 FILL_1_DIGIT(1,0,wert_lo);
55 #define FILL_2 FILL_2_DIGIT(2,0,wert_lo);
56 #define FILL_3 FILL_1_DIGIT(3,2,wert_hi); FILL_2_DIGIT(3,0,wert_lo);
57 #define FILL_4 FILL_2_DIGIT(4,2,wert_hi); FILL_2_DIGIT(4,0,wert_lo);
60 #define FILL_1 FILL_1_DIGIT(1,0,wert_lo);
61 #define FILL_2 FILL_2_DIGIT(2,0,wert_lo);
62 #define FILL_3 FILL_3_DIGIT(3,0,wert_lo);
63 #define FILL_4 FILL_4_DIGIT(4,0,wert_lo);
64 #define FILL_5 FILL_1_DIGIT(5,4,wert_hi); FILL_4_DIGIT(5,0,wert_lo);
65 #define FILL_6 FILL_2_DIGIT(6,4,wert_hi); FILL_4_DIGIT(6,0,wert_lo);
66 #define FILL_7 FILL_3_DIGIT(7,4,wert_hi); FILL_4_DIGIT(7,0,wert_lo);
67 #define FILL_8 FILL_4_DIGIT(8,4,wert_hi); FILL_4_DIGIT(8,0,wert_lo);
70 #define IF_LENGTH(i) \
71 if ((bn_minlength <= i) && (i*intDsize <= 64) \
72 && (!((i+1)*intDsize <= 64) \
73 || (i*intDsize-1 < 32 \
74 ? ((wert_hi == 0) && (wert_lo < (uint32)bitc(i*intDsize-1))) \
75 : ((uint32)wert_hi < (uint32)bitc(i*intDsize-1-32)) \
78 var cl_heap_bignum* ptr = allocate_bignum(i);
80 return (cl_private_thing)(ptr);
82 bignum1: { ALLOC(1); FILL_1; OK; }
85 bignum2: { ALLOC(2); FILL_2; OK; }
88 bignum3: { ALLOC(3); FILL_3; OK; }
90 bignum4: { ALLOC(4); FILL_4; OK; }
93 bignum5: { ALLOC(5); FILL_5; OK; }
95 bignum6: { ALLOC(6); FILL_6; OK; }
97 bignum7: { ALLOC(7); FILL_7; OK; }
99 bignum8: { ALLOC(8); FILL_8; OK; }
105 #define IF_LENGTH(i) \
106 if ((bn_minlength <= i) && (i*intDsize <= 64) \
107 && (!((i+1)*intDsize <= 64) \
108 || (i*intDsize-1 < 32 \
109 ? ((wert_hi == ~(sint32)0) && (wert_lo >= (uint32)(-bitc(i*intDsize-1)))) \
110 : ((uint32)wert_hi >= (uint32)(-bitc(i*intDsize-1-32))) \