7 #include "cln/integer.h"
17 uintC integer_length (const cl_I& x)
20 { var uintL bitcount = 0;
21 var uintV x_ = FN_to_V(x); // x als intVsize-Bit-Zahl
22 if (FN_V_minusp(x,(sintV)x_)) { x_ = ~ x_; } // falls <0, komplementieren
25 integerlength64(x_,bitcount=);
27 integerlength32(x_,bitcount=);
30 return bitcount; // 0 <= bitcount < intVsize.
33 { var const uintD* MSDptr;
35 BN_to_NDS_nocopy(x, MSDptr=,len=,); // normalisierte DS zu x bilden.
36 var uintC bitcount = intDsize*(len-1); // Anzahl Digits mal intDsize
37 // MSDigit nehmen, testen, welches das höchste Bit ist, das vom
38 // Vorzeichenbit abweicht:
39 var uintD msd = mspref(MSDptr,0); // MSDigit
40 if ((sintD)msd < 0) { msd = ~msd; } // falls negativ, invertieren
41 // Position des höchsten Bits in msd suchen und entsprechend bit_count
42 // erhöhen (um höchstens intDsize-1):
43 if (!(msd == 0)) { integerlengthD(msd, bitcount += ); }
44 return bitcount; // 0 <= bitcount < intDsize*2^intCsize.