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.
>>>= operator is the unsigned right shift assignment operator in Dart. It performs a bitwise logical right shift on the left operand by the number of bit positions specified by the right operand, and then assigns the resulting value back to the left operand.
Unlike the arithmetic right shift assignment (>>=), which performs sign extension by preserving the sign bit, the >>>= operator always shifts zeros into the most significant (leftmost) bits. This occurs regardless of whether the original integer’s two’s complement representation is positive or negative.
Syntax
Mechanics and Constraints
- Operand Types: Because
>>>=is a compound assignment evaluated asa = a >>> b, the target variableacan be of any custom type that overloadsoperator >>>. The shift amountbcan be of any type accepted by that specific overload. For built-in bitwise operations, both operands are typically of typeint. - Bit Discarding: The
bleast significant (rightmost) bits ofaare shifted out of the binary sequence and discarded. - Zero Padding:
bnumber of0bits are inserted starting from the most significant (leftmost) bit downwards. - Negative Shift Amounts: For built-in integers, the shift amount (
b) must be non-negative. Passing a negative shift amount to a shift operator throws anArgumentError(or a subclass such asRangeError, depending on the compiler) at runtime. - Overshifting: The behavior of shifting by an amount greater than or equal to the integer’s bit-width depends entirely on the compilation platform.
Platform-Specific Execution
Because Dart compiles to both native machine code and JavaScript, the underlying bit-width of integers dictates the exact numerical output of this operator:- Native Platforms (VM, AOT): Integers are 64-bit. Applying
>>>=to a negative number shiftsbzeros in starting from the 64th bit downwards, resulting in a very large positive 64-bit integer. If the shift amountbis greater than or equal to 64, the result evaluates to0. - Web Platforms (dart2js, DDC): Bitwise operations are truncated to 32-bit integers to comply with JavaScript’s bitwise mechanics. The
bzeros are shifted in starting from the 32nd bit downwards. Additionally, the shift amountbis masked to 5 bits (evaluated asb % 32). Therefore, shifting by 32 is equivalent to shifting by 0, which does not universally result in0(e.g.,-8 >>> 32evaluates to4294967288).
Code Visualization
Master Dart with Deep Grasping Methodology!Learn More





