-
Notifications
You must be signed in to change notification settings - Fork 8
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
added logical shift operations #45
base: main
Are you sure you want to change the base?
Conversation
source/bits/lshiftl.ts
Outdated
* Shifts all given bits to left and returns the resulting bits | ||
* | ||
* @example | ||
* lshiftl([1,0,1,1,0,1]) => [0,1,1,0,1,0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xflotus can you make a case for this not returning [1,0,1,1,0,1,0]
instead? bitwise
basically supports arbitrary size bit arrays, so perhaps this is an unexpected result
If you have a particular use-case in mind for the non-size-increasing version, we could also add a flag for this behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 6 Bits in the example and you are referring to 7 Bits. Which case should it return?
source/bits/lshiftr.ts
Outdated
* Shifts all given bits to right and returns the resulting bits | ||
* | ||
* @example | ||
* lshiftr([1,0,1,1,0,1]) => [0,1,0,1,1,0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not as concerned about this one, but I suppose it’s possible to argue that the leading 0
should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure?
@0xflotus I merged the circular shift one as it was obvious how it should behave on arbitrary lengths of bits (doesn’t modify length). However, I’m really not sure about this one and if it’s more reasonable to keep the length or to decrease/increase it by |
part 1 of fix #44