System.Numerics.BigIntegerBuilder.Mul C# (CSharp) Méthode

Mul() public méthode

public Mul ( BigIntegerBuilder &reg1, BigIntegerBuilder &reg2 ) : void
reg1 BigIntegerBuilder
reg2 BigIntegerBuilder
Résultat void
        public void Mul(ref BigIntegerBuilder reg1, ref BigIntegerBuilder reg2) {
            if (reg1._iuLast == 0) {
                if (reg2._iuLast == 0) {
                    this.Set((ulong)reg1._uSmall * (ulong)reg2._uSmall);
                }
                else {
                    this.Load(ref reg2, 1);
                    this.Mul(reg1._uSmall);
                }
            }
            else if (reg2._iuLast == 0) {
                this.Load(ref reg1, 1);
                this.Mul(reg2._uSmall);
            }
            else {
                uint[] numArray;
                uint[] numArray2;
                int num;
                int num2;
                this.SetSizeClear((reg1._iuLast + reg2._iuLast) + 2);
                if (reg1.CuNonZero <= reg2.CuNonZero) {
                    numArray = reg1._rgu;
                    num = reg1._iuLast + 1;
                    numArray2 = reg2._rgu;
                    num2 = reg2._iuLast + 1;
                }
                else {
                    numArray = reg2._rgu;
                    num = reg2._iuLast + 1;
                    numArray2 = reg1._rgu;
                    num2 = reg1._iuLast + 1;
                }
                for (int i = 0; i < num; i++) {
                    uint num4 = numArray[i];
                    if (num4 != 0) {
                        uint uCarry = 0;
                        int index = i;
                        int num7 = 0;
                        while (num7 < num2) {
                            uCarry = AddMulCarry(ref this._rgu[index], num4, numArray2[num7], uCarry);
                            num7++;
                            index++;
                        }
                        while (uCarry != 0) {
                            uCarry = AddCarry(ref this._rgu[index++], 0, uCarry);
                        }
                    }
                }
                this.Trim();
            }
        }

Same methods

BigIntegerBuilder::Mul ( BigIntegerBuilder &regMul ) : void
BigIntegerBuilder::Mul ( uint u ) : void

Usage Example

        /// <summary>Multiplies two specified <see cref="BigInteger" /> values.</summary>
        /// <returns>The product of <paramref name="left" /> and <paramref name="right" />.</returns>
        /// <param name="left">The first value to multiply.</param>
        /// <param name="right">The second value to multiply.</param>
        public static BigInteger operator *(BigInteger left, BigInteger right)
        {
            var sign     = 1;
            var regLeft  = new BigIntegerBuilder(left, ref sign);
            var regRight = new BigIntegerBuilder(right, ref sign);

            regLeft.Mul(ref regRight);
            return(regLeft.GetInteger(sign));
        }
All Usage Examples Of System.Numerics.BigIntegerBuilder::Mul