Determining combination of bits
Grant Edwards
grante at visi.com
Mon Nov 8 18:22:01 EST 2004
On 2004-11-08, Diez B. Roggisch <deetsNOSPAM at web.de> wrote:
>> A lapse of mind?
>>>>> n = 6
>>>>> n & (-n)
>> 2
>>
>> You probably meant n&1 or perhaps n%2.
>
> No, the exact right thing: 6 is binary
>
> 110
>
> with the least significant bit beeing
>
> 10
The least significant bit of 110 is this one here -----+
^ |
| |
+-----------------------+
It's a 0 (zero).
What I think you're trying to say is something like the value
of the rightmost 1.
--
Grant Edwards grante Yow! The PINK SOCKS were
at ORIGINALLY from 1952!! But
visi.com they went to MARS around
1953!!
More information about the Python-list
mailing list