]> www.ginac.de Git - cln.git/blob - src/integer/conv/cl_I_from_DS.cc
Replace unused macro with cl_unused.
[cln.git] / src / integer / conv / cl_I_from_DS.cc
1 // DS_to_I().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "integer/cl_I.h"
8
9
10 // Implementation.
11
12 #include "cln/number.h"
13 #include "base/digitseq/cl_DS.h"
14
15 #include "base/cl_inline.h"
16 #include "integer/conv/cl_I_from_NDS.cc"
17
18 namespace cln {
19
20 CL_INLINE2 const cl_I CL_INLINE2_DECL(DS_to_I) (const uintD* MSDptr, uintC len)
21 {
22       // erst normalisieren.
23       // Dabei evtl. MSDptr erhöhen und len erniedrigen:
24       if (!(len==0)) // leere DS ist normalisiert
25         { var uintC count = len-1;
26           if ((sintD)mspref(MSDptr,0) >= 0)
27             // Zahl >= 0
28             { // versuche maximal len-1 führende Nullen-Digits zu streichen:
29               while (!(count==0) && (mspref(MSDptr,0)==0) && ((sintD)mspref(MSDptr,1)>=0))
30                 { msshrink(MSDptr); len--; count--; } // Nulldigit streichen
31             }
32             else
33             // Zahl < 0
34             // versuche maximal len-1 führende Einsen-Digits zu streichen:
35             { while (!(count==0) && ((sintD)mspref(MSDptr,0)==-1) && ((sintD)mspref(MSDptr,1)<0))
36                 { msshrink(MSDptr); len--; count--; } // Einsen-digit streichen
37         }   }
38       // Eventuell ist jetzt noch bei der DS 0 ausnahmsweise len=1,
39       // aber NDS_to_I wird auch damit fertig.
40       return NDS_to_I_inline(MSDptr,len);
41 }
42
43 }  // namespace cln