operator << method

Uint128 operator <<(
  1. int n
)

Logical left shift. Each step here is a plain Uint64 shift/bitwise op — already proven web-safe in Uint64 itself — so no additional safety trick is needed at this width.

Implementation

Uint128 operator <<(int n) {
  final shift = n & 127;
  if (shift == 0) return this;
  if (shift < 64) {
    final newHi = (_hi << shift) | (_lo >> (64 - shift));
    final newLo = _lo << shift;
    return Uint128._(newHi, newLo);
  }
  final s = shift - 64;
  return Uint128._(_lo << s, Uint64.zero);
}