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.
<< (bitwise left shift) operator shifts the binary representation of an integer to the left by a specified number of bit positions. As the bits are shifted left, the high-order (leftmost) bits are discarded, and zero bits are shifted in from the right to fill the vacated low-order positions.
Operands
target: The baseintwhose bits are being manipulated.shiftAmount: A non-negativeintdictating the number of bit positions to shift. If this value is negative, Dart throws anArgumentError.
Mechanics
Dart integers are 64-bit two’s complement numbers on native platforms. The<< operator performs a logical left shift on this 64-bit sequence.
Mathematically, evaluating a << b is equivalent to multiplying a by , provided the operation does not result in an overflow beyond the integer limit of the underlying platform.
Syntax Visualization
Positive Integer Shift:Platform Specifics
Because Dart compiles to both native machine code and JavaScript, the behavior of<< diverges based on the compilation target:
- Dart Native (VM/AOT): Operates on 64-bit two’s complement integers. High-order bits are discarded only when they exceed the 64th bit. Shifting by 32 performs a literal 32-bit shift.
- Dart Web (JavaScript): JavaScript bitwise operations implicitly convert operands to 32-bit signed integers. This introduces three critical behavioral differences:
- Target Truncation: The
targetis truncated to 32 bits before the shift occurs. - Shift Amount Masking: The
shiftAmountis masked to 5 bits (modulo 32). Consequently, shifting by 32 on the web results in a shift of 0 (returning the original number unmodified), whereas native platforms shift by the full 32 positions. - Result Constraint: The final result of the shift is constrained to a 32-bit signed integer. This alters the result even for small targets if the shifted value exceeds 31 bits. For example,
1 << 31evaluates to2147483648on native platforms, but wraps to-2147483648on the web due to 32-bit signed integer overflow.
- Target Truncation: The
Master Dart with Deep Grasping Methodology!Learn More





