12 #include "cln/number.h"
17 cl_private_thing cl_I_constructor_from_UL2 (uint32 wert_hi, uint32 wert_lo)
20 && ((wert_lo & minus_bit(cl_value_len-1)) == 0)
22 return (cl_private_thing)(cl_combine(cl_FN_tag,wert_lo));
24 // (dessen Länge bn_minlength <= n <= ceiling((64+1)/intDsize) erfüllt)
25 #define UL2_maxlength ceiling(64+1,intDsize)
26 #define FILL_1_DIGIT(l,i,from) \
27 arrayLSref(ptr->data,l,i) = (uintD)from;
28 #define FILL_2_DIGIT(l,i,from) \
29 arrayLSref(ptr->data,l,i) = (uintD)from; \
30 arrayLSref(ptr->data,l,i+1) = (uintD)(from>>intDsize);
31 #define FILL_3_DIGIT(l,i,from) \
32 arrayLSref(ptr->data,l,i) = (uintD)from; from>>=intDsize; \
33 arrayLSref(ptr->data,l,i+1) = (uintD)from; \
34 arrayLSref(ptr->data,l,i+2) = (uintD)(from>>intDsize);
35 #define FILL_4_DIGIT(l,i,from) \
36 arrayLSref(ptr->data,l,i) = (uintD)from; from>>=intDsize; \
37 arrayLSref(ptr->data,l,i+1) = (uintD)from; from>>=intDsize; \
38 arrayLSref(ptr->data,l,i+2) = (uintD)from; \
39 arrayLSref(ptr->data,l,i+3) = (uintD)(from>>intDsize);
41 #define FILL_1 FILL_1_DIGIT(1,0,highlow64(wert_hi,wert_lo));
42 #define FILL_2 FILL_1_DIGIT(2,1,0); FILL_1_DIGIT(2,0,highlow64(wert_hi,wert_lo));
45 #define FILL_1 FILL_1_DIGIT(1,0,wert_lo);
46 #define FILL_2 FILL_1_DIGIT(2,1,wert_hi); FILL_1_DIGIT(2,0,wert_lo);
47 #define FILL_3 FILL_1_DIGIT(3,2,0); FILL_1_DIGIT(3,1,wert_hi); FILL_1_DIGIT(3,0,wert_lo);
50 #define FILL_1 FILL_1_DIGIT(1,0,wert_lo);
51 #define FILL_2 FILL_2_DIGIT(2,0,wert_lo);
52 #define FILL_3 FILL_1_DIGIT(3,2,wert_hi); FILL_2_DIGIT(3,0,wert_lo);
53 #define FILL_4 FILL_2_DIGIT(4,2,wert_hi); FILL_2_DIGIT(4,0,wert_lo);
54 #define FILL_5 FILL_1_DIGIT(5,4,0); FILL_2_DIGIT(5,2,wert_hi); FILL_2_DIGIT(5,0,wert_lo);
57 #define FILL_1 FILL_1_DIGIT(1,0,wert_lo);
58 #define FILL_2 FILL_2_DIGIT(2,0,wert_lo);
59 #define FILL_3 FILL_3_DIGIT(3,0,wert_lo);
60 #define FILL_4 FILL_4_DIGIT(4,0,wert_lo);
61 #define FILL_5 FILL_1_DIGIT(5,4,wert_hi); FILL_4_DIGIT(5,0,wert_lo);
62 #define FILL_6 FILL_2_DIGIT(6,4,wert_hi); FILL_4_DIGIT(6,0,wert_lo);
63 #define FILL_7 FILL_3_DIGIT(7,4,wert_hi); FILL_4_DIGIT(7,0,wert_lo);
64 #define FILL_8 FILL_4_DIGIT(8,4,wert_hi); FILL_4_DIGIT(8,0,wert_lo);
65 #define FILL_9 FILL_1_DIGIT(9,8,0); FILL_4_DIGIT(9,4,wert_hi); FILL_4_DIGIT(9,0,wert_lo);
67 #define IF_LENGTH(i) \
68 if ((bn_minlength <= i) && (i <= UL2_maxlength)) \
69 if (!(i+1 <= UL2_maxlength) \
70 || (i*intDsize-1 < 32 \
71 ? ((wert_hi == 0) && (wert_lo < (uint32)bitc(i*intDsize-1))) \
72 : (wert_hi < (uint32)bitc(i*intDsize-1-32)) \
75 var cl_heap_bignum* ptr = allocate_bignum(i);
77 return (cl_private_thing)(ptr);
79 { ALLOC(1); FILL_1; OK; }
81 { ALLOC(2); FILL_2; OK; }
84 { ALLOC(3); FILL_3; OK; }
87 { ALLOC(4); FILL_4; OK; }
89 { ALLOC(5); FILL_5; OK; }
92 { ALLOC(6); FILL_6; OK; }
94 { ALLOC(7); FILL_7; OK; }
96 { ALLOC(8); FILL_8; OK; }
98 { ALLOC(9); FILL_9; OK; }