Bit TEST, SET, etc operators.
Jose E. Marchesi
jemarch@gnu.org
Mon Feb 2 20:36:37 GMT 2026
Hello James.
> Greetings All,
>
> It is exciting to be able to use the new bit operators, am already
> using them to implement a "bit reversed counter" to allow efficient
> bit reversed addressing for various FFT implementations.
>
> Question: is the decision to use "NUMBIT is ONE based" a firm decision?
>
> In doing so, we are loser the nice mathematical property wherein a
> bit's position (NUMBIT) is associated with its power of 2.
>
> With one based we have:
> b_3*2^2 + b_2*2^1 + b_1*2^0 in general b_i*2^(i-1)
> instead of:
> b_2*2^2 + b_1*2^1 + b_0*2^0 in general b_i*2^i
>
> It's not the end of the world, but can be a bit awkward and might be
> more error prone (for math-related).
This is a very good question.
The SET, CLEAR and TEST operators are oriented to the view of a `bits'
as a packet set of bits, rather than as a multiple of booleans. So I
think it would be ok to use zero based indexes if we wanted to.
That said, I think I still prefer the one based indexes, if only because
it maches better with the indexing of multiples that is so very often
used in iterations.
Do you have some particular practical problem that would benefit from
the zero based indexing?
More information about the Algol68
mailing list