]> www.ginac.de Git - cln.git/blob - src/integer/bitwise/cl_I_lognot.cc
Finalize CLN 1.3.7 release.
[cln.git] / src / integer / bitwise / cl_I_lognot.cc
1 // lognot().
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 #include "integer/bitwise/cl_I_log.h"
15
16 namespace cln {
17
18 const cl_I lognot (const cl_I& x)
19     { if (fixnump(x)) // Fixnum -> ganz einfach:
20         { // bitweise als Fixnum zurück
21           return cl_I_from_word(x.word ^ cl_combine(0,~(cl_uint)0));
22         }
23         else
24         // Bignum:
25         { CL_ALLOCA_STACK;
26           var uintD* MSDptr;
27           var uintC n;
28           BN_to_NDS(x, MSDptr=,n=,); // NDS zu x bilden
29           // Es ist n>=bn_minlength,
30           // und die ersten intDsize+1 Bit sind nicht alle gleich.
31           not_loop_msp(MSDptr,n); // mit NOT komplementieren,
32                           // wegen n>0 wird auch das Vorzeichenbit umgedreht
33           // MSDptr/n/LSDptr ist immer noch eine NDS, da n>=bn_minlength
34           // und die ersten intDsize+1 Bit nicht alle gleich sind.
35           return NDS_to_I(MSDptr,n); // Ergebnis als Integer
36     }   }
37
38 }  // namespace cln