internal FastInteger2 Multiply(int val)
{
if (val == 0) {
this.smallValue = 0;
this.integerMode = 0;
} else {
switch (this.integerMode) {
case 0:
bool apos = this.smallValue > 0L;
bool bpos = val > 0L;
if (
(apos && ((!bpos && (Int32.MinValue / this.smallValue) > val) ||
(bpos && this.smallValue > (Int32.MaxValue / val)))) ||
(!apos && ((!bpos && this.smallValue != 0L &&
(Int32.MaxValue / this.smallValue) > val) ||
(bpos && this.smallValue < (Int32.MinValue / val))))) {
// would overflow, convert to large
if (apos && bpos) {
// if both operands are nonnegative
// convert to mutable big integer
this.integerMode = 1;
this.mnum = new MutableNumber(this.smallValue);
this.mnum.Multiply(val);
} else {
// if either operand is negative
// convert to big integer
this.integerMode = 2;
this.largeValue = (EInteger)this.smallValue;
this.largeValue *= (EInteger)val;
}
} else {
smallValue *= val;
}
break;
case 1:
if (val < 0) {
this.integerMode = 2;
this.largeValue = this.mnum.ToEInteger();
this.largeValue *= (EInteger)val;
} else {
mnum.Multiply(val);
}
break;
case 2:
this.largeValue *= (EInteger)val;
break;
default: throw new InvalidOperationException();
}
}
return this;
}