Dear comp.lang.python,
When I asked ChatGPT how I would get the number of zero bits in a Python
integer, it spouted some nonsense about calculating it with
( n & -n ).bit_length() - 1
but that hardly seems like the best way. Specifically, I'm trying to
count the number of zero bits to the
On 9/20/2026 2:23 AM, Stefan Ram wrote:
"Johann \"Myrkraverk\" Oskarsson" wrote or quoted:
The above formula seems to work, given a few spot checks, but I thought
this should be a utility function in the underlying multiprecision lib-
rary in Python. Is the calculation n & -n really
On 9/20/2026 4:32 AM, Johann "Myrkraverk" Oskarsson wrote:
On 9/20/2026 3:37 AM, Lane W wrote:
Johann "Myrkraverk" Oskarsson wrote:
On 9/20/2026 2:23 AM, Stefan Ram wrote:
"Johann \"Myrkraverk\" Oskarsson" wrote
or quoted:
The above formula seems to work, given a few spot checks, but I
On 9/20/2026 4:39 AM, Stefan Ram wrote:
"Johann \"Myrkraverk\" Oskarsson" wrote or quoted:
it really should be simpler to just
count the zero bits in the underlying C code.
Why can't we do that?
You /can/ ask your chatbot to generate a C extension that
On 9/20/2026 3:37 AM, Lane W wrote:
Johann "Myrkraverk" Oskarsson wrote:
On 9/20/2026 2:23 AM, Stefan Ram wrote:
"Johann \"Myrkraverk\" Oskarsson" wrote
or quoted:
The above formula seems to work, given a few spot checks, but I thought
this should be a utility function in the underlying
Johann "Myrkraverk" Oskarsson wrote:
On 9/20/2026 2:23 AM, Stefan Ram wrote:
"Johann \"Myrkraverk\" Oskarsson" wrote or
quoted:
The above formula seems to work, given a few spot checks, but I thought
this should be a utility function in the underlying multiprecision lib-
rary in Python. Is