BigInt(0xffffffff) << BigInt(32)
will return the proper 18446744069414584320n
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Left_shift#description
For BigInts, there's no truncation. Conceptually, understand positive BigInts as having an infinite number of leading
0
bits, and negative BigInts having an infinite number of leading1
bits.
Current definition of <<
operator for BigInt
: https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#sec-numeric-types-bigint-leftShift
Diff between BigInt
and number
: https://tc39.es/proposal-bigint/#sec-bitwise-shift-operators