]> www.ginac.de Git - cln.git/blob - src/integer/elem/cl_I_minus1.cc
Use paths relative the `src' directory in the #include directives.
[cln.git] / src / integer / elem / cl_I_minus1.cc
1 // minus1().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "cln/integer.h"
8
9
10 // Implementation.
11
12 #include "integer/cl_I.h"
13 #include "base/digitseq/cl_DS.h"
14
15 namespace cln {
16
17 const cl_I minus1 (const cl_I& x)
18 {
19         if (fixnump(x))
20           { // x ist Fixnum
21             if (x.word != cl_combine(cl_FN_tag,bit(cl_value_len-1)))
22                 // bleibt Fixnum: direkt 1 subtrahieren
23                 // This assumes cl_value_shift + cl_value_len == cl_pointer_size.
24                 { return cl_I_from_word(x.word - cl_combine(0,1)); }
25           }
26         // die sichere Methode
27         { CL_ALLOCA_STACK;
28           var uintD* MSDptr;
29           var uintC len;
30           var uintD* LSDptr;
31           I_to_NDS_1(x, MSDptr=,len=,LSDptr=); // NDS zu x bilden.
32           DS_minus1_plus(LSDptr,len); // von der NDS 1 subtrahieren
33           return DS_to_I(MSDptr,len); // wieder zum Integer machen
34         }
35 }
36
37 }  // namespace cln