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

A question about __PackedArray_pack_ code #4

Open
NanXiao opened this issue Feb 28, 2019 · 3 comments · May be fixed by #5
Open

A question about __PackedArray_pack_ code #4

NanXiao opened this issue Feb 28, 2019 · 3 comments · May be fixed by #5
Labels

Comments

@NanXiao
Copy link

NanXiao commented Feb 28, 2019

Hi @gpakosz ,

Greeting from me!

I am reading PackedArray's code, and come across the following statement:

packed |= *out & ~((uint32_t)(1ULL << ((((uint64_t)count * (uint64_t)PACKEDARRAY_IMPL_BITS_PER_ITEM + startBit - 1) % 32) + 1)) - 1);

Why not just use:

packed |= *out & ~((uint32_t)(1ULL << (((uint64_t)count * (uint64_t)PACKEDARRAY_IMPL_BITS_PER_ITEM + startBit) % 32)) - 1)

What is the difference between these two methods?

Thanks very much in advance!

Bets Regards
Nan Xiao

@gpakosz
Copy link
Owner

gpakosz commented Feb 28, 2019

Hello @NanXiao 👋

Right off the bat, I don't remember why it's written this way.
If you replace the existing code by your suggestion, do all the tests still pass?

@NanXiao
Copy link
Author

NanXiao commented Feb 28, 2019

@gpakosz

Thanks very much for your quick response!

I modify the code, and at least PackedArraySelfTest passes the tests.

When you have time, could you double-check?

Thanks!

@gpakosz
Copy link
Owner

gpakosz commented Mar 1, 2019

@NanXiao

I had a second quick look. I can't remember why it's written this way but your suggestion looks good to me. I may have goofed the night I wrote the original code 🤷‍♂️

sa-tasche added a commit to mitgd-learning/PackedArray that referenced this issue Mar 24, 2021
Signed-off-by: Sara Dolores Tasche <sara.dolores.tasche@gmail.com>
@sa-tasche sa-tasche linked a pull request Mar 24, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants