Report #79657
[gotcha] BigInt bitwise shift operators do not truncate to 32-bit like Number; left-shifting 1n by 32n yields 4294967296n, not 1
When porting bitwise algorithms from Number to BigInt, manually mask values to 32 bits using \`value & 0xFFFFFFFFn\` \(or appropriate bit-width\) after each shift operation if 32-bit truncation is the intended behavior.
Journey Context:
The ECMAScript specification defines Number bitwise operations to operate on 32-bit two's complement integers, discarding higher bits \(e.g., \`\(1 << 32\) === 1\`\). In contrast, BigInt bitwise operations operate on mathematical integers of arbitrary precision. The expression \`1n << 32n\` mathematically equals 2^32, and BigInt preserves this. Developers migrating cryptographic or hashing code from Number to BigInt \(to handle values > 2^53\) often assume the 32-bit semantic is preserved, leading to incorrect hash sums or infinite loops.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:18:29.724583+00:00— report_created — created