4 #include "base/cl_sysdep.h"
7 #include "cln/integer.h"
12 #include "cln/number.h"
13 #include "integer/cl_I.h"
14 #include "base/digitseq/cl_DS.h"
16 #include "cln/integer_io.h"
17 #include "cln/exception.h"
22 uint32 cl_I_to_UL (const cl_I& obj)
26 var sintV wert = FN_to_V(obj);
34 var cl_heap_bignum* bn = TheBignum(obj);
35 var uintC len = bn->length;
36 if ((sintD)mspref(arrayMSDptr(bn->data,len),0) < 0)
38 #define IF_LENGTH(i) \
39 if ((bn_minlength <= i) /* genau i Digits überhaupt möglich? */ \
40 && (len == i) /* genau i Digits? */ \
41 /* 2^((i-1)*intDsize-1) <= obj < 2^(i*intDsize-1) */ \
42 && ( (i*intDsize-1 > 32) \
43 && ( ((i-1)*intDsize-1 >= 32) \
44 || (mspref(arrayMSDptr(bn->data,len),0) >= (uintD)bitc(32-(i-1)*intDsize)) \
49 return get_uint1D_Dptr(arrayLSDptr(bn->data,1));
51 return get_uint2D_Dptr(arrayLSDptr(bn->data,2));
53 return get_uint3D_Dptr(arrayLSDptr(bn->data,3));
55 return get_uint4D_Dptr(arrayLSDptr(bn->data,4));
57 return get_uint4D_Dptr(arrayLSDptr(bn->data,5));
60 bad: // unpassendes Objekt
61 std::ostringstream buf;
62 fprint(buf, "Not a 32-bit integer: ");
64 throw runtime_exception(buf.str());