mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
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:
parent
ec37eadb39
commit
945d962322
4 changed files with 15 additions and 5 deletions
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue