mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:58:11 +00:00
LibJS: Fix that leftshift for BigInts did not round down
For negative number this previously rounded towards zero instead of the intended always rounding down.
This commit is contained in:
parent
cb49c07fb7
commit
e663504df1
3 changed files with 37 additions and 4 deletions
|
@ -64,3 +64,13 @@ test("shifting with non-numeric values", () => {
|
|||
expect(Infinity >> Infinity).toBe(0);
|
||||
expect(-Infinity >> Infinity).toBe(0);
|
||||
});
|
||||
|
||||
describe("logical right shift on big ints", () => {
|
||||
expect(3n >> 1n).toBe(1n);
|
||||
expect(3n >> 2n).toBe(0n);
|
||||
expect(-3n >> 1n).toBe(-2n);
|
||||
expect(-3n >> 2n).toBe(-1n);
|
||||
expect(-3n >> 128n).toBe(-1n);
|
||||
expect(-3n >> -6n).toBe(-192n);
|
||||
expect(-3n >> 0n).toBe(-3n);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue