12 #include "cln/number.h"
14 #if (cl_word_size < 64)
20 cl_private_thing cl_I_constructor_from_UL2 (uint32 wert_hi, uint32 wert_lo)
23 && ((wert_lo & minus_bit(cl_value_len-1)) == 0)
25 return (cl_private_thing)(cl_combine(cl_FN_tag,wert_lo));
27 // (dessen Länge bn_minlength <= n <= ceiling((64+1)/intDsize) erfüllt)
28 #define UL2_maxlength ceiling(64+1,intDsize)
29 #define FILL_1_DIGIT(l,i,from) \
30 arrayLSref(ptr->data,l,i) = (uintD)from;
31 #define FILL_2_DIGIT(l,i,from) \
32 arrayLSref(ptr->data,l,i) = (uintD)from; \
33 arrayLSref(ptr->data,l,i+1) = (uintD)(from>>intDsize);
34 #define FILL_3_DIGIT(l,i,from) \
35 arrayLSref(ptr->data,l,i) = (uintD)from; from>>=intDsize; \
36 arrayLSref(ptr->data,l,i+1) = (uintD)from; \
37 arrayLSref(ptr->data,l,i+2) = (uintD)(from>>intDsize);
38 #define FILL_4_DIGIT(l,i,from) \
39 arrayLSref(ptr->data,l,i) = (uintD)from; from>>=intDsize; \
40 arrayLSref(ptr->data,l,i+1) = (uintD)from; from>>=intDsize; \
41 arrayLSref(ptr->data,l,i+2) = (uintD)from; \
42 arrayLSref(ptr->data,l,i+3) = (uintD)(from>>intDsize);
44 #define FILL_1 FILL_1_DIGIT(1,0,highlow64(wert_hi,wert_lo));
45 #define FILL_2 FILL_1_DIGIT(2,1,0); FILL_1_DIGIT(2,0,highlow64(wert_hi,wert_lo));
48 #define FILL_1 FILL_1_DIGIT(1,0,wert_lo);
49 #define FILL_2 FILL_1_DIGIT(2,1,wert_hi); FILL_1_DIGIT(2,0,wert_lo);
50 #define FILL_3 FILL_1_DIGIT(3,2,0); FILL_1_DIGIT(3,1,wert_hi); FILL_1_DIGIT(3,0,wert_lo);
53 #define FILL_1 FILL_1_DIGIT(1,0,wert_lo);
54 #define FILL_2 FILL_2_DIGIT(2,0,wert_lo);
55 #define FILL_3 FILL_1_DIGIT(3,2,wert_hi); FILL_2_DIGIT(3,0,wert_lo);
56 #define FILL_4 FILL_2_DIGIT(4,2,wert_hi); FILL_2_DIGIT(4,0,wert_lo);
57 #define FILL_5 FILL_1_DIGIT(5,4,0); FILL_2_DIGIT(5,2,wert_hi); FILL_2_DIGIT(5,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);
68 #define FILL_9 FILL_1_DIGIT(9,8,0); FILL_4_DIGIT(9,4,wert_hi); FILL_4_DIGIT(9,0,wert_lo);
70 #define IF_LENGTH(i) \
71 if ((bn_minlength <= i) && (i <= UL2_maxlength)) \
72 if (!(i+1 <= UL2_maxlength) \
73 || (i*intDsize-1 < 32 \
74 ? ((wert_hi == 0) && (wert_lo < (uint32)bitc(i*intDsize-1))) \
75 : (wert_hi < (uint32)bitc(i*intDsize-1-32)) \
78 var cl_heap_bignum* ptr = allocate_bignum(i);
80 return (cl_private_thing)(ptr);
82 { ALLOC(1); FILL_1; OK; }
84 { ALLOC(2); FILL_2; OK; }
87 { ALLOC(3); FILL_3; OK; }
90 { ALLOC(4); FILL_4; OK; }
92 { ALLOC(5); FILL_5; OK; }
95 { ALLOC(6); FILL_6; OK; }
97 { ALLOC(7); FILL_7; OK; }
99 { ALLOC(8); FILL_8; OK; }
101 { ALLOC(9); FILL_9; OK; }