[fpc-pascal] Bitcounting

Martin fpc at mfriebe.de
Sat Mar 5 19:15:26 CET 2016


On 05/03/2016 18:03, Bart wrote:
> Hi,
>
> Does FreePascal have a routine for counting bits?
> So that e.g. BitCount(%1001100100001) gives 5 (number of bits that are 1)?
>
> I came up with (extracted from IntToBin()):
>
Have a look at
http://stackoverflow.com/questions/3815165/how-to-implement-bitcount-using-only-bitwise-operators



More information about the fpc-pascal mailing list