>>=) is a compound assignment operator that performs a bitwise arithmetic right shift on the left operand by the number of bit positions specified by the right operand, and subsequently assigns the result back to the left operand.
Syntax
Operational Mechanics
- Type Constraint: Both operands must be of type
int. - Bitwise Shift: The binary representation of
variableis shifted to the right bynumberOfBits. - Sign Extension: Dart uses arithmetic shifting. The empty bit positions created on the left (most significant bits) are filled with the value of the original sign bit:
- If the number is positive (sign bit
0),0s are shifted in. - If the number is negative (sign bit
1),1s are shifted in to preserve the sign in two’s complement representation.
- If the number is positive (sign bit
- Truncation: Bits shifted off the right end (least significant bits) are discarded.
- Assignment: The resulting integer value is stored in
variable.
Examples
Positive Integer Shift Shifting a positive integer fills the most significant bits with0.
1.
Master Dart with Deep Grasping Methodology!Learn More





