Re: [PATCH 1/5] lib: add find_nth(,and,andnot)_bit()
From: Yury Norov
Date: Fri Jul 08 2022 - 12:41:04 EST
On Fri, Jul 8, 2022 at 2:13 AM Andy Shevchenko
> On Fri, Jul 8, 2022 at 10:55 AM Rasmus Villemoes
> <linux@xxxxxxxxxxxxxxxxxx> wrote:
> > On 07/07/2022 23.03, Yury Norov wrote:
> > >> And I don't
> > >> like that the index is apparently 1-based (and that surprising API isn't
> > >> spelled out anywhere).
> > >
> > > Yeah... My motivation to start counting from 1 is to keep consistency
> > > with ffs: __ffs(word) <=> fns(word, 1).
> > I understand that you're translating that second f in ffs (find First
> > set) to a 1. But I disagree that that's necessarily a logical thing to
> > do. Everybody understands that (given a C or python or... context) when
> > some prose talks about "the first element in an array", it's the one at
> > . So I find it much more natural that the set bits in a word are
> > enumerated 0, 1, ..., popcount(w)-1.
> I agree that here we operate with an array of bits, which naturally
> starts from bit 0.
OK, I'll send v2 shortly