Ruud H.G. van Tol on Fri, 04 Jul 2025 16:16:09 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: flags in a bitmap |
[switched from user to dev] On 2025-07-04 15:51, Bill Allombert wrote:
On Fri, Jul 04, 2025 at 12:38:59PM +0200, Ruud H.G. van Tol wrote:? install(bitset,vWL) ? x=2^(2^20); ? forprime(p=2,2^20,bitset(~x,p)) *** last result computed in 8 ms. ? my(S=0);for(i=0,2^20-1,S+=bittest(x,i));S %16 = 82025 *** last result computed in 159 ms.That indeed looks good, and I can test it.Great, I have made a GIT branch bill-bitset commit 8632eaf7528554234aaa90d9a503476452cbd736 (HEAD -> bill-bitset, origin/bill-bitset, master) Author: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr> Date: Thu Jul 3 23:57:00 2025 +0200 New GP functions bitset, bitclear
Thanks. First (minor) remark: -Help: bitclear(~n,i): clear bit i of n (in place) +Help: bitclear(~x,n): clear bit n of x (in place) -Help: bitset(~n,i): set bit i of n in place +Help: bitset(~x,n): set bit n of x in place to align it with bittest, and with the code. -- Ruud