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
Bitwise methods #281
base: master
Are you sure you want to change the base?
Bitwise methods #281
Conversation
Hello again. |
A quick first test of let n = new BigNumber(4);
n = n.bitShiftRight(1);
console.log(n.toString()); // '4'
console.log(4 >> 1); // 2 |
fixed that |
console.log(BigNumber(9).and(57).toString()); // 2
console.log(9 & 57); // 9
console.log(BigNumber(8).or(38).toString()); // 11
console.log(8 | 38); // 46
console.log(BigNumber(34).xor(89).toString()); // 61
console.log(34 ^ 89); // 123
console.log(BigNumber(84).not().toString()); // NaN
console.log(~84); // -85 |
oh i forgot tests, that would be important |
Hello, can I help this feature? |
Yea I think you'd just need to write tests dealing with all the methods dealing with special cases too for replicating the behaviour of Edit: Feel free to open PR over at |
Hi everyone, I submitted an PR at Vap0r1ze:bitwise . I have a doubt, that you can answer too @MikeMcl , we can put all these test together in the same file? |
Add test cases and fix and method
@MikeMcl there is some issue here? |
Yes. BigInt(-3) & BigInt(4) // 4n
BigNumber(-3).and(4).toString() // '0' BigNumber bitiwse operations need to match BigInt. It's been a while since I looked at this but I remember working on it a bit and getting the results to match but I wasn't happy with the performance due to it using string operations and applying native bitwise ops one bit at a time. I currently have: |
Hiya Mike, It's me from #106 I'm opening a fresh PR since I deleted my old fork. I believe I addressed all of your concerns, but it's pretty late so I wouldn't be surprised if I missed something. Let me know what else there is to be done, or any issues you have with the PR in its current state.