Skip to main content
The >>= operator is the bitwise right shift assignment operator in Dart. It performs an arithmetic (sign-propagating) right shift on the binary representation of the left operand by the number of bits specified by the right operand, and subsequently assigns the computed value back to the left operand.
This operation is syntactically equivalent to the expanded assignment:

Technical Mechanics

  • Operand Constraints: Both the left operand (the value being mutated) and the right operand (the shift magnitude) must be of type int.
  • Sign Propagation: Dart integers utilize two’s complement binary representation. The >>= operator performs an arithmetic shift, meaning it preserves the most significant bit (the sign bit) during the shift.
    • If the left operand is positive (sign bit 0), empty spaces on the left are filled with 0s.
    • If the left operand is negative (sign bit 1), empty spaces on the left are filled with 1s.
  • Truncation: The least significant bits that are shifted past the 0th position on the right are permanently discarded.

Syntax Visualization

(Note: If zero-fill/logical right shift assignment is required regardless of the sign bit, Dart provides the >>>= operator instead).
Tired of Poor Dart Skills? Fix That With Deep Grasping!Learn More