]> www.ginac.de Git - cln.git/blob - src/integer/bitwise/cl_I_log_aux.cc
* All Files have been modified for inclusion of namespace cln;
[cln.git] / src / integer / bitwise / cl_I_log_aux.cc
1 // I_to_DS_n_aux().
2 // General includes.
3 #include "cl_sysdep.h"
4
5 // Specification.
6 #include "cl_I_log.h"
7
8
9 // Implementation.
10
11 #include "cln/number.h"
12 #include "cl_I.h"
13 #include "cl_DS.h"
14
15 namespace cln {
16
17 uintD* I_to_DS_n_aux (const cl_I& obj, uintC n, uintD* destptr)
18     { // Nun sind unterhalb von destptr n Digits Platz.
19       // oberen Teil der DS aus obj füllen, dabei destptr erniedrigen:
20       if (fixnump(obj))
21         // Fixnum:
22         {
23           #if (intDsize==64) // && (FN_maxlength==1)
24            lsprefnext(destptr) = FN_to_Q(obj);
25           #else // (intDsize<=32)
26            var uint32 wert = FN_to_L(obj);
27            #define FN_maxlength_a  (intLsize/intDsize)
28            #define FN_maxlength_b  (FN_maxlength<=FN_maxlength_a ? FN_maxlength : FN_maxlength_a)
29            // FN_maxlength Digits ablegen. Davon kann man FN_maxlength_b Digits aus wert nehmen.
30            #if (FN_maxlength_b > 1)
31            doconsttimes(FN_maxlength_b-1,
32              lsprefnext(destptr) = (uintD)wert; wert = wert >> intDsize;
33              );
34            #endif
35            lsprefnext(destptr) = (uintD)wert;
36            #if (FN_maxlength > FN_maxlength_b)
37            // Es ist oint_data_len = intLsize, brauche
38            // noch FN_maxlength-FN_maxlength_b = 1 Digit.
39            lsprefnext(destptr) = (sintD)sign_of(FN_to_L(obj));
40            #endif
41           #endif
42           n -= FN_maxlength;
43         }
44         else
45         // Bignum:
46         { var uintC len = TheBignum(obj)->length;
47           n -= len;
48           destptr = copy_loop_lsp(BN_LSDptr(obj),destptr,len); // DS kopieren
49         }
50       // unteren Teil mit Fülldigits, gebildet aus dem Vorzeichen, füllen:
51       if (!(n==0))
52         { destptr = fill_loop_lsp(destptr,n,sign_of_sintD(mspref(destptr,0))); }
53       // destptr zeigt nun aufs untere Ende der DS.
54       return destptr;
55     }
56
57 }  // namespace cln
58