LibJS+LibCrypto: Fix SignedBitInteger::bitwise_not and use it in LibJS

Bitwise operators are defined on two's complement, but SignedBitInteger
uses sign-magnitude. Correctly convert between the two.

Let LibJS delegate to SignedBitInteger for bitwise_not, like it does
for all other bitwise_ operations on bigints.

No behavior change (LibJS is now the only client of
SignedBitInteger::bitwise_not()).
This commit is contained in:
Nico Weber 2022-01-17 12:22:51 -05:00 committed by Ali Mohammad Pur
commit 945d962322
Notes: sideshowbarker 2024-07-17 20:40:21 +09:00
4 changed files with 15 additions and 5 deletions

View file

@ -40,6 +40,8 @@ describe("correct behavior", () => {
expect(1n | 2n).toBe(3n);
expect(5n ^ 3n).toBe(6n);
expect(~1n).toBe(-2n);
expect(~-1n).toBe(0n);
expect(5n << 2n).toBe(20n);
expect(7n >> 1n).toBe(3n);
});