Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSB0 Bit String Reversal is Not Reversible #343

Closed
hmorris94 opened this issue Aug 6, 2024 · 3 comments
Closed

LSB0 Bit String Reversal is Not Reversible #343

hmorris94 opened this issue Aug 6, 2024 · 3 comments
Assignees
Milestone

Comments

@hmorris94
Copy link

When bitstring.options.lsb0 == False, bitstring.BitArray('0xf0a')[::-1][::-1] returns BitArray('0xf0a').

However, when bitstring.options.lsb0 == True, bitstring.BitArray('0xf0a')[::-1][::-1] returns BitArray('0xc2').

@scott-griffiths
Copy link
Owner

Hi. Thanks for the bug report, that's really useful.

It looks like the initial and final two bits have been lost somehow. I'm away this week so can't debug what's happening here, but I'll take a proper look and get a fix in when I'm back.

Thanks.

@scott-griffiths
Copy link
Owner

This is a general problem when converting LSB0 slices with a negative step into their equivalent MSB0 slices, which can cut off some bits in some cases.

I'll add a fix soon , which will be in the next point release

@scott-griffiths scott-griffiths added this to the 4.2.4 milestone Aug 15, 2024
scott-griffiths added a commit that referenced this issue Aug 16, 2024
There are still some wierd edge cases possible, see TODO in test case.
@scott-griffiths scott-griffiths modified the milestones: 4.2.4, 4.3 Oct 30, 2024
@scott-griffiths
Copy link
Owner

I think this is now fixed - or at least I can't find an example to break it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants