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

Support bitwise operation #60

Open
yyyoungha opened this issue Sep 12, 2020 · 12 comments · May be fixed by #63
Open

Support bitwise operation #60

yyyoungha opened this issue Sep 12, 2020 · 12 comments · May be fixed by #63
Labels
enhancement New feature or request operators: bitwise Bitwise operators
Milestone

Comments

@yyyoungha
Copy link

yyyoungha commented Sep 12, 2020

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 ( >>= )
@faheel
Copy link
Owner

faheel commented Oct 5, 2020

Sure! It would be nice to have bitwise operators.

@faheel faheel added enhancement New feature or request operators: bitwise Bitwise operators labels Oct 5, 2020
@faheel faheel added this to the v1.0 milestone Oct 5, 2020
@muytingc
Copy link

muytingc commented Nov 5, 2020

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.

@faheel
Copy link
Owner

faheel commented Nov 6, 2020

@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.

@harish-vnkt
Copy link

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?

@faheel
Copy link
Owner

faheel commented Nov 20, 2020

@harish-vnkt Since there's no PR currently for this issue you can feel free to create one.

@arenbecl
Copy link

arenbecl commented Dec 6, 2020

@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?

@Priyanshi-Chauhan
Copy link

Can I make my first contribution in bitwise. I am new to open source!!

@aniketh-varma
Copy link

Is the issue still relevant ? @faheel

@cristian-5
Copy link

we need bitwise operations

@faheel faheel linked a pull request Dec 18, 2022 that will close this issue
@faheel
Copy link
Owner

faheel commented Dec 18, 2022

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.

@GNL10
Copy link

GNL10 commented Feb 8, 2023

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.

@ZuoFuhong
Copy link

ZuoFuhong commented Jul 17, 2023

I recommend using the gmp library as it is more mature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request operators: bitwise Bitwise operators
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants