Closed Yaffle closed 6 years ago
I'm looking at the specification for it, and I can't find this behavior documented anywhere. Am I missing it somewhere?
I'm curious why they would want to return 0
and 1
for large arguments? Do you have any idea?
just because the operation "a << b" works only when both args are bigints (as all other Arithmetic and Bitwise operations).
and 0n >> -100000000000000000000n
is equal to 0 * 2**100000000000000000000
...
Is it possible to change the behavior of shiftRightand shiftLeft to match how BigInt works (https://github.com/tc39/proposal-bigint) with large second argument?
bigInt(0).shiftRight(-100000000000000000000)
should givebigInt(0)
bigInt(0).shiftLeft(100000000000000000000)
should givebigInt(0)
bigInt(5).shiftRight(100000000000000000000)
should givebigInt(0)
bigInt(5).shiftLeft(-100000000000000000000)
should givebigInt(0)
bigInt(-5).shiftRight(100000000000000000000)
should givebigInt(-1)
bigInt(-5).shiftLeft(-100000000000000000000)
should givebigInt(-1)