X-Git-Url: https://ginac.de/CLN/cln.git//cln.git?a=blobdiff_plain;ds=inline;f=src%2Finteger%2Fbitwise%2Fcl_I_logcount.cc;h=62a1814b2c30e751d88d91f93735568c97beaf51;hb=c84c6db5d56829d69083c819688a973867694a2a;hp=50bf4db71a237686efef817e15542c8ef5e29296;hpb=dd9e0f894eec7e2a8cf85078330ddc0a6639090b;p=cln.git diff --git a/src/integer/bitwise/cl_I_logcount.cc b/src/integer/bitwise/cl_I_logcount.cc index 50bf4db..62a1814 100644 --- a/src/integer/bitwise/cl_I_logcount.cc +++ b/src/integer/bitwise/cl_I_logcount.cc @@ -4,7 +4,7 @@ #include "cl_sysdep.h" // Specification. -#include "cl_integer.h" +#include "cln/integer.h" // Implementation. @@ -14,24 +14,34 @@ #include "cl_D.h" #include "cl_low.h" -uintL logcount (const cl_I& x) +namespace cln { + +uintC logcount (const cl_I& x) { if (fixnump(x)) - { var uint32 x32 = FN_to_L(x); // x als 32-Bit-Zahl - if (FN_L_minusp(x,(sint32)x32)) { x32 = ~ x32; } // falls <0, komplementieren + { var uintV x32 = FN_to_V(x); // x als intDsize-Bit-Zahl + if (FN_V_minusp(x,(sintV)x32)) { x32 = ~ x32; } // falls <0, komplementieren + #if (intVsize>32) + #define x64 x32 + logcount_64(); // Bits von x32 zählen + #undef x64 + #else logcount_32(); // Bits von x32 zählen + #endif return x32; } else { var const uintD* MSDptr; var uintC len; BN_to_NDS_nocopy(x, MSDptr=,len=,); // DS zu x bilden, len>0. - var uintL bitcount = 0; // Bitzähler + var uintC bitcount = 0; // Bitzähler var const uintD* ptr = MSDptr; // läuft durch die Digits durch var uintD sign = sign_of_sintD(mspref(ptr,0)); // Vorzeichen dotimespC(len,len, - { bitcount += (uintL)logcountD(msprefnext(ptr) ^ sign); }); + { bitcount += (uintC)logcountD(msprefnext(ptr) ^ sign); }); // 0 <= bitcount < intDsize*2^intCsize. return bitcount; } } + +} // namespace cln