operator << method
T
operator <<(
- dynamic other
将此整数的位向左shiftAmount
。
向左移动会使数字变大,有效地将数字乘以pow(2, shiftIndex) 。
结果的大小没有限制。通过使用带有合适掩码的“and”运算符来限制中间值可能是相关的。
如果shiftAmount
为负数,则为错误
结果超出bits时,将溢出范围,具体参考toSigned
Implementation
T operator <<(dynamic other) {
if (other is AbstractInt) {
return valueOf(value << other.value);
} else if (other is int) {
return valueOf(value << other);
} else if (other is BigInt) {
return valueOf(value << other.toInt());
} else if (other is Decimal) {
return valueOf(value << other.toBigInt().toInt());
} else {
throw UnsupportedError('not support argument: ${other.runtimeType}');
}
}