Re: bit_ffs

"Ruud H.G. van Tol" <[email protected]>
Newsgroups gmane.comp.mathematics.pari.devel
Message-ID <[email protected]>
On 2023-03-30 19:43, Ruud H.G. van Tol wrote:
> On 2023-03-30 19:02, Ruud H.G. van Tol wrote:
>> Might be interesting to add:
>>
>> https://en.wikipedia.org/wiki/Find_first_set
>> https://www.man7.org/linux/man-pages/man3/ffs.3.html
>> https://www.go4expert.com/articles/builtin-gcc-functions-builtinclz-t29238/ 
>>
>>
>> Or are those too low-level?
>>
>> bit_ffs, bit_ctz
>
> Count trailing set bits:
>
> bit_cts(n) = logint( 1 + bitand(n, bitneg(n) - 1), 2 )

Similar:

   bit_cts(n) = logint( bitand( bitneg(n), n + 1 ), 2 )

-- Ruud
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.