TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
>>> (unsigned right shift) operator shifts the binary representation of the first operand to the right by the number of bits specified by the second operand, shifting in zeroes from the left. Unlike the sign-propagating right shift (>>), it does not preserve the sign bit, guaranteeing that the evaluated result is always a non-negative 32-bit unsigned integer.
Technical Mechanics
When the JavaScript engine evaluates a>>> operation, it performs the following sequence of internal steps:
- Type Coercion: The left
operandis converted to a 32-bit integer. For the purposes of this specific operator, it is treated as a 32-bit unsigned integer (Uint32). - Shift Masking: The
shiftAmountis converted to a 32-bit integer and masked to 5 bits using a bitwise AND (shiftAmount & 0x1F). This ensures the actual shift amount is always an integer between0and31inclusive. - Bit Shifting: The bits of the left operand are moved to the right by the calculated shift amount.
- Zero-Fill: As bits are shifted to the right,
0bits are inserted from the far left (the most significant bit position). - Truncation: Any bits shifted past the 0th position (the least significant bit) are permanently discarded.
BigInt Incompatibility
In JavaScript,>>> is the only bitwise operator that does not support BigInt operands. Because BigInt values represent arbitrary-precision integers and lack a fixed bit-width, the concept of filling zeroes from a fixed leftmost boundary does not apply. Attempting to use >>> with a BigInt operand throws a TypeError.
Behavioral Examples
Positive Integers
For positive integers,>>> behaves identically to >> because the sign bit is already 0.
Negative Integers
For negative integers, the behavior diverges significantly from>>. Negative numbers are represented in 32-bit two’s complement, meaning their leftmost bit (sign bit) is 1. Because >>> forces zeroes in from the left, the sign bit is overwritten, resulting in a large positive integer.
Shift Amount Modulo
Because the right operand is masked to 5 bits, shifting by32 is equivalent to shifting by 0.
Non-Integer Coercion
If the left operand is a non-integer, JavaScript truncates the fractional part during the 32-bit integer conversion before applying the shift. If the operand cannot be converted to a number (e.g.,NaN, undefined), it is coerced to 0.
Master JavaScript with Deep Grasping Methodology!Learn More





