scott-griffiths / bitstring

A Python module to help you manage your bits
https://bitstring.readthedocs.io/en/stable/index.html
MIT License
404 stars 68 forks source link

lsb0 Breaks Bitshifting #251

Closed hmorris94 closed 1 year ago

hmorris94 commented 1 year ago

When lsb0 is False, this operation behaves as expected. (Actually better than expected in that it preserves the array size!)

a = bitstring.BitArray(bin="11001")

(a << 1).b
'10010'
(a >> 1).b
'01100'

When lsb0 is True, behavior is a little funny.

(a << 1).b
'11000'
(a >> 1).b
'01001'
scott-griffiths commented 1 year ago

Yep, that behaviour is definitely a little funny! The behaviour for << and >> shouldn't depend on the value of the lsb0 flag at all.

Should be an easy fix along with a few other lsb0 fixes I have in progress. Many thanks for bringing it to my attention.

scott-griffiths commented 1 year ago

Fixed in 4.0.2