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

Add functions for bitwise operations #4028

Closed
haozhun opened this issue Nov 24, 2015 · 5 comments
Closed

Add functions for bitwise operations #4028

haozhun opened this issue Nov 24, 2015 · 5 comments

Comments

@haozhun
Copy link
Contributor

haozhun commented Nov 24, 2015

Considerations:

  • future support of DECIMAL types
  • same result regardless of type
  • not commit to stores numbers as two's complement internally

Functions that are insensitive to width of numbers:

BITWISE_NOT(1) = -2 -- document as bitwise NOT in two's complement arithmetic
BITWISE_AND(91, 15) = 11
BITWISE_OR(32, 3) = 35
BITWISE_XOR(17, 5) = 20
BITWISE_ARSH(-8, 2) = -2

Function that has tricky overflow issue:

BITWISE_LSH(7, 2, 4) = 12 -- treat 7 as a 4-bit signed number and left shift by 2,
                          -- truncate overflow

Function that are inherently sensitive to width of numbers:

BITWISE_LRSH(-8, 2, 5) = 6 -- treat -8 as a 5-bit signed number and lsh by 2
BITCOUNT(-8, 6) = 3 -- treat -8 as a 6-bit signed number and count 1s
                    -- alias POPCOUNT

Placeholder functions:

BITWISE_RSH: tell user to choose one of BITWISE_ARSH and BITWISE_LRSH
BITWISE_LRSH: tell user to provide 3rd parameter
BITCOUNT: tell user to provide 2nd parameter
BITWISE_LSH: tell user to provide 3rd parameter
@haozhun haozhun self-assigned this Nov 24, 2015
@haozhun
Copy link
Contributor Author

haozhun commented Nov 24, 2015

@martint Please take a look.

@haozhun
Copy link
Contributor Author

haozhun commented Dec 2, 2015

@martint Does the proposed function signatures look right to you?

@stale
Copy link

stale bot commented Apr 3, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@tdcmeehan
Copy link
Contributor

Reopening since bitshift functions are still outstanding

@stale
Copy link

stale bot commented Jun 2, 2021

This issue has been automatically marked as stale because it has not had any activity in the last 2 years. If you feel that this issue is important, just comment and the stale tag will be removed; otherwise it will be closed in 7 days. This is an attempt to ensure that our open issues remain valuable and relevant so that we can keep track of what needs to be done and prioritize the right things.

@stale stale bot added the stale label Jun 2, 2021
@stale stale bot closed this as completed Jun 29, 2021
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

3 participants