-
-
Notifications
You must be signed in to change notification settings - Fork 199
Fix signed version of radix_sort #3724
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
Conversation
Why not define the projection outside and only apply it when there's signed integers? otherwise, LGTM. |
Good catch - allows for making the logic quite a bit more expressive, thanks. |
Reusing schnellerhase#24. On
On this branch:
Has some impact. |
Best guess would be that we now always max out the iteration count |
We only need to do the sign flip in case we detect a negative number, maybe check at runtime and use the unmodified projection if no casting is necessary? |
After optimisation for first bit (ignore for order if all set)
|
@IgorBaratta is this ready to me merged? |
LGTM! |
Fixes bug in
radix_sort
, reported by @jorgensd, for signed integers where bitwise comparison failed and resulted in either infinite loops or unsorted result.Fixes it by radix sort only working on unsigned ints internally and inputs with signed getting shifted to corresponding unsigned int ranges.