Re: [fpc-pascal] Bitcounting

2016-03-06 Thread David W Noon
On Sat, 5 Mar 2016 19:03:24 +0100, Bart (bartjun...@gmail.com) wrote about "[fpc-pascal] Bitcounting" (in ): > Does FreePascal have a routine for counting bits? [snip] > Surely this can be done better? If you don't mind a bit of

Re: [fpc-pascal] Bitcounting

2016-03-06 Thread Jesus Reyes A.
En Sat, 05 Mar 2016 12:03:24 -0600, Bart escribió: Hi, Does FreePascal have a routine for counting bits? So that e.g. BitCount(%100110011) gives 5 (number of bits that are 1)? I came up with (extracted from IntToBin()): function BitCount(N: Int64): Integer; var

Re: [fpc-pascal] Bitcounting

2016-03-05 Thread Bart
On 3/5/16, Jonas Maebe wrote: > The "compilerproc" modifier does not influence code generation other > than symbol mangling. You can just look at the implementation in the > system unit like for any other routine. Lazarus code-tools didn't get me there ;-) Found it

Re: [fpc-pascal] Bitcounting

2016-03-05 Thread Jonas Maebe
On 05/03/16 23:12, Bart wrote: On 3/5/16, Jonas Maebe wrote: >FPC 3.x has system.popcnt Thanks. I see it's a compilerproc. How can I see how it'simplemented? The "compilerproc" modifier does not influence code generation other than symbol mangling. You can just

Re: [fpc-pascal] Bitcounting

2016-03-05 Thread Bart
On 3/5/16, Jonas Maebe wrote: > FPC 3.x has system.popcnt Thanks. I see it's a compilerproc. How can I see how it'simplemented? Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] Bitcounting

2016-03-05 Thread Santiago A.
El 05/03/16 a las 19:03, Bart escribió: > Hi, > > Does FreePascal have a routine for counting bits? > So that e.g. BitCount(%100110011) gives 5 (number of bits that are 1)? > > I came up with (extracted from IntToBin()): > > function BitCount(N: Int64): Integer; > var > Q: QWord; > i:

Re: [fpc-pascal] Bitcounting

2016-03-05 Thread Jonas Maebe
On 05/03/16 19:03, Bart wrote: Does FreePascal have a routine for counting bits? So that e.g. BitCount(%100110011) gives 5 (number of bits that are 1)? FPC 3.x has system.popcnt Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] Bitcounting

2016-03-05 Thread Jeppe Johansen
The PopCount functions do exactly that. On 03/05/2016 07:03 PM, Bart wrote: Hi, Does FreePascal have a routine for counting bits? So that e.g. BitCount(%100110011) gives 5 (number of bits that are 1)? I came up with (extracted from IntToBin()): function BitCount(N: Int64): Integer; var

Re: [fpc-pascal] Bitcounting

2016-03-05 Thread Martin
On 05/03/2016 18:03, Bart wrote: Hi, Does FreePascal have a routine for counting bits? So that e.g. BitCount(%100110011) gives 5 (number of bits that are 1)? I came up with (extracted from IntToBin()): Have a look at

Re: [fpc-pascal] Bitcounting

2016-03-05 Thread Philippe Lévi
sorry ... need change intToStr in my suggestion by something like intToStrBin length( strChange( intToStrBin( N, '0', '')); but it is just for fun! De: fpc-pascal-boun...@lists.freepascal.org em nome de Bart