Ruud H.G. van Tol on Fri, 31 Mar 2023 17:25:41 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
- To: pari-dev@pari.math.u-bordeaux.fr
- Subject: Re: bit_ffs
- From: "Ruud H.G. van Tol" <rvtol@isolution.nl>
- Date: Fri, 31 Mar 2023 17:24:20 +0200
- Delivery-date: Fri, 31 Mar 2023 17:25:41 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=simple/simple; d=isolution.nl; s=soverin; t=1680276263; bh=Air27GZSQTR+twqs6Aj5KajM7GMBmVna/rhIUn4vvak=; h=Date:Subject:To:References:From:In-Reply-To:From; b=oPtXKEd1NqoiTh7E53rcjtMCa2W7HmD6yU1ALPO3VPQwcRSQ1EFiACYoKNXZiu82B j0uPMD+rFEja+TkGvSA+CUmu+imfJk6RNLDhTkA9ezKiGhYYGyqVVImXmMIMRdiBrl us/2fg49KCK1WG93IwXGEencxoRRSrImzTAh0CDTLI2w7diXoFgJTjj45njbgK98uZ AE+6s9CnWM55ITxhVV6KT/YzayddICt5dCLqz9/NDEIw60NHGTqclLIq16lEa2ifcu CWXaomMXAJFpRaQKbD/KhYKkw0GomRR07t671zId4zbBBZhIovEEXnyrGxSdjqG1xm 3CpBQP2uBEn6A==
- In-reply-to: <ZCXQShfVlYFA3SeK@seventeen>
- References: <684b63b3-ab0e-bbac-a45f-a3e87421227c@isolution.nl> <ZCXQShfVlYFA3SeK@seventeen>
On 2023-03-30 20:09, Bill Allombert wrote:
On Thu, Mar 30, 2023 at 07:02:34PM +0200, 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
For the bitxxx functions family in GP,
you can use valuation(x,2) (resp. logint(x,2))
Find first set bit:
bit_ffs(n) = valuation(n, 2)
Count trailing set bits:
bit_cts(n) = valuation(n+1, 2)
-- Ruud
- References:
- bit_ffs
- From: "Ruud H.G. van Tol" <rvtol@isolution.nl>
- Re: bit_ffs
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>