7 #include "cl_integer.h"
15 uintL integer_length (const cl_I& x)
18 { var uintL bitcount = 0;
19 var uint32 x_ = FN_to_L(x); // x als 32-Bit-Zahl
20 if (FN_L_minusp(x,(sint32)x_)) { x_ = ~ x_; } // falls <0, komplementieren
21 if (!(x_==0)) { integerlength32(x_,bitcount=); }
22 return bitcount; // 0 <= bitcount < 32.
25 { var const uintD* MSDptr;
27 BN_to_NDS_nocopy(x, MSDptr=,len=,); // normalisierte DS zu x bilden.
28 var uintL bitcount = intDsize*(uintL)(len-1); // Anzahl Digits mal intDsize
29 // MSDigit nehmen, testen, welches das höchste Bit ist, das vom
30 // Vorzeichenbit abweicht:
31 var uintD msd = mspref(MSDptr,0); // MSDigit
32 if ((sintD)msd < 0) { msd = ~msd; } // falls negativ, invertieren
33 // Position des höchsten Bits in msd suchen und entsprechend bit_count
34 // erhöhen (um höchstens intDsize-1):
35 if (!(msd == 0)) { integerlengthD(msd, bitcount += ); }
36 return bitcount; // 0 <= bitcount < intDsize*2^intCsize.