operator * method
Multiply, keeping only the low 32 bits (wrapping). Two 32-bit
magnitudes multiplied directly can reach ~2^64 — unsafe as a double
on web — so this decomposes into 16-bit limbs first, the same way
Uint64.operator* does.
Implementation
Int32 operator *(Int32 other) {
final a = _bits, b = other._bits;
final aLo = a & BinaryOps.mask16, aHi = (a >>> 16) & BinaryOps.mask16;
final bLo = b & BinaryOps.mask16, bHi = (b >>> 16) & BinaryOps.mask16;
final lo = aLo * bLo; // < 2^32, safe
final cross =
(aLo * bHi + aHi * bLo) &
BinaryOps.mask16; // terms < 2^32, sum < 2^33, safe
final result =
(lo + (cross << 16)) & BinaryOps.mask32; // both terms < 2^32, safe
return Int32._(result);
}