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

Error comment on bit twiddling trick #33

Open
Kingfish404 opened this issue Jan 28, 2023 · 1 comment
Open

Error comment on bit twiddling trick #33

Kingfish404 opened this issue Jan 28, 2023 · 1 comment

Comments

@Kingfish404
Copy link

x = (x | (x >> 16)); /* Set x=-1 if j&6=0, else x=0 */

should be

/* Set x=0xFFFFFFFFFFFFFFFF if x=0xFFFFFFFFFFFF0000, else x=0 */
// or
/* Set x=-1 if j%6=0, else x=0 */ 

It's clearly that the 2's complement of -1 is 0xFFFFFFFFFFFF0000 and there is no logic for j&6.

This Error has been copied or spread for so many repos.

@crozone
Copy link
Owner

crozone commented Feb 1, 2023

Agreed, comment should be /* Set x=0xFFFFFFFFFFFFFFFF if x=0xFFFFFFFFFFFF0000, else x=0 */, although maybe something like:

/* Bitwise OR the upper bytes of x over the lower two bytes of x, such that if x was 0xFFFFFFFFFFFF0000, it becomes 0xFFFFFFFFFFFFFFFF. Otherwise, if x was 0, it remains as 0 */

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

No branches or pull requests

2 participants