Support bitwise operation
Why don't we add bitwise operators here?
Features for bitwise operation
1. bitwise opeartors
- bitwise OR ( | )
- bitwise AND ( & )
- bitwise XOR ( ^ )
- bitwise NOT ( ~ )
- bitwise LEFT SHIFT ( << )
- bitwise RIGHT SHIFT ( >> )
2. bitwise-assignment opeartors
- bitwise-assignment OR ( |= )
- bitwise-assignment AND ( &= )
- bitwise-assignment XOR ( ^= )
- bitwise-assignment LEFT SHIFT ( <<= )
- bitwise-assignment RIGHT SHIFT ( >>= )
Sure! It would be nice to have bitwise operators.
I'd be interested in working on working on this issue. This would be my first contribution to an open-sourced project, so I'm not sure if there's a formal way to get assigned to it (the contribution guidelines seemed like just to leaving a note in the issue was enough), but I didn't see anyone else assigned to it so I thought I'd throw my hat in the ring.
@muytingc Sure, you can work on it! There's no need to be assigned to an issue - if you don't find an open pull request (PR) for an issue then you can submit a PR with your code (the PR doesn't even need to have all of the functionality in the beginning). Then in the PR comments and code review you can clear your doubts, if any, and we can iron out the finer details of the implementation.
Hi @faheel, first-time contributor here. I have implemented the left-shift and right-shift operations so far. Can I open a pull request for them or will it conflict with @muytingc's work?
@harish-vnkt Since there's no PR currently for this issue you can feel free to create one.
@faheel When implementing bitwise NOT, would it be more useful to assume that the binary representation of the BigInt stops at the highest 1 bit, or add additional 0 bits up to the nearest power of 2?
Can I make my first contribution in bitwise. I am new to open source!!
Is the issue still relevant ? @faheel
we need bitwise operations
Sorry for the late reply. #63 is a high-quality PR by @arenbecl that adds almost all bitwise operators, but is missing test cases. If anyone is interested in contributing they can add test cases by creating a fork of https://github.com/arenbecl/BigInt/tree/bitwise-assignment-operators and sending another PR.
Hi, @faheel I created a PR with the tests for this issue. There is something which must be discussed, though, please see the comments in the PR.
I recommend using the gmp library as it is more mature.