Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static BigInteger operator *(BigInteger left, BigInteger right)
- {
- int sign = 1;
- BigIntegerBuilder bigIntegerBuilder = new BigIntegerBuilder(left, ref sign);
- BigIntegerBuilder bigIntegerBuilder2 = new BigIntegerBuilder(right, ref sign);
- bigIntegerBuilder.Mul(ref bigIntegerBuilder2);
- return bigIntegerBuilder.GetInteger(sign);
- }
- ...
- public void Mul(ref BigIntegerBuilder regMul)
- {
- if (regMul._iuLast == 0)
- {
- this.Mul(regMul._uSmall);
- return;
- }
- if (this._iuLast == 0)
- {
- uint uSmall = this._uSmall;
- if (uSmall == 1u)
- {
- this = new BigIntegerBuilder(ref regMul);
- return;
- }
- if (uSmall != 0u)
- {
- this.Load(ref regMul, 1);
- this.Mul(uSmall);
- return;
- }
- }
- else
- {
- int num = this._iuLast + 1;
- this.SetSizeKeep(num + regMul._iuLast, 1);
- int num2 = num;
- while (--num2 >= 0)
- {
- uint uMul = this._rgu[num2];
- this._rgu[num2] = 0u;
- uint num3 = 0u;
- for (int i = 0; i <= regMul._iuLast; i++)
- {
- num3 = BigIntegerBuilder.AddMulCarry(ref this._rgu[num2 + i], regMul._rgu[i], uMul, num3);
- }
- if (num3 != 0u)
- {
- int num4 = num2 + regMul._iuLast + 1;
- while (num3 != 0u && num4 <= this._iuLast)
- {
- num3 = BigIntegerBuilder.AddCarry(ref this._rgu[num4], 0u, num3);
- num4++;
- }
- if (num3 != 0u)
- {
- this.SetSizeKeep(this._iuLast + 2, 0);
- this._rgu[this._iuLast] = num3;
- }
- }
- }
- }
- }
- ...
- private static uint AddMulCarry(ref uint uAdd, uint uMul1, uint uMul2, uint uCarry)
- {
- ulong num = (ulong)uMul1 * (ulong)uMul2 + (ulong)uAdd + (ulong)uCarry;
- uAdd = (uint)num;
- return (uint)(num >> 32);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement