]> www.ginac.de Git - cln.git/blob - src/integer/bitwise/cl_I_lognot.cc
7ce1685edeb94aceba9e131afe24760627f6ac66
[cln.git] / src / integer / bitwise / cl_I_lognot.cc
1 // lognot().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_integer.h"
8
9
10 // Implementation.
11
12 #include "cl_I.h"
13 #include "cl_DS.h"
14 #include "cl_I_log.h"
15
16 const cl_I lognot (const cl_I& x)
17     { if (fixnump(x)) // Fixnum -> ganz einfach:
18         { // bitweise als Fixnum zurück
19           return cl_I_from_word(x.word ^ cl_combine(0,~(cl_uint)0));
20         }
21         else
22         // Bignum:
23         { CL_ALLOCA_STACK;
24           var uintD* MSDptr;
25           var uintC n;
26           BN_to_NDS(x, MSDptr=,n=,); // NDS zu x bilden
27           // Es ist n>=bn_minlength,
28           // und die ersten intDsize+1 Bit sind nicht alle gleich.
29           not_loop_msp(MSDptr,n); // mit NOT komplementieren,
30                           // wegen n>0 wird auch das Vorzeichenbit umgedreht
31           // MSDptr/n/LSDptr ist immer noch eine NDS, da n>=bn_minlength
32           // und die ersten intDsize+1 Bit nicht alle gleich sind.
33           return NDS_to_I(MSDptr,n); // Ergebnis als Integer
34     }   }