[Tutor] Extracting bits from an array
Alan Gauld
alan.gauld at yahoo.co.uk
Fri Apr 29 19:50:55 EDT 2016
On 29/04/16 20:47, Anish Kumar wrote:
>> Is the number of bits fixed to four? If so you can shift the bits to the
>> right:
>>
>>>>> y = [v>>2 for v in x]
>
> Right shifting is well defined in Python?
Yes, Python has good support for all the common bitwise
operations, including the shift right/left operators.
Read the documentation for the limitations.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list