Determining combination of bits

Mitja nun at example.com
Mon Nov 8 18:30:18 EST 2004


Diez B. Roggisch 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
>
> thus the decimal value of 2.

Wow. I always thought "least significant bit" meant, in the common big-endian bit notation, the last bit - with emphasis on the bit
word, i.e. either 1 or 0.
Have I got a real mess in my head (probably not, I just googled for definitions and the onse I checked are consistent with what I
wrote, http://www.google.com/search?hl=en&lr=&q=%22least+significant+bit%22) or is the meaning of the phrase poorly defined?





More information about the Python-list mailing list