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

Feature request: Add bitwise operators on integer64 #33

Open
dvg-p4 opened this issue May 21, 2024 · 1 comment
Open

Feature request: Add bitwise operators on integer64 #33

dvg-p4 opened this issue May 21, 2024 · 1 comment

Comments

@dvg-p4
Copy link

dvg-p4 commented May 21, 2024

Bitwise AND/OR and left/right shifts would be very useful when working with integers that are encoding multiple sub-values based on bit position.

@dvg-p4
Copy link
Author

dvg-p4 commented May 21, 2024

Workaround: use combinations of %% 2^n, %/% 2^n, * 2^n to extract and manipulate contiguous bits.

E.g. to emulate bitwise AND with 0b111110000 and extract bits 9 to 5:

> input
integer64
[1] 123456789 987654321
> as.bitstring(input)
[1] "0000000000000000000000000000000000000111010110111100110100010101" "0000000000000000000000000000000000111010110111100110100010110001"
> as.bitstring(input %% 2^9 %/% 2^4 * 2^4)
[1] "0000000000000000000000000000000000000000000000000000000100010000" "0000000000000000000000000000000000000000000000000000000010110000"

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

1 participant