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

Add() public méthode

public Add ( uint u ) : void
u uint
Résultat void
        public void Add(uint u) {
            if (this._iuLast == 0) {
                if ((this._uSmall += u) < u) {
                    this.SetSizeLazy(2);
                    this._rgu[0] = this._uSmall;
                    this._rgu[1] = 1;
                }
            }
            else if (u != 0) {
                uint num = this._rgu[0] + u;
                if (num < u) {
                    this.EnsureWritable(1);
                    this.ApplyCarry(1);
                }
                else if (!this._fWritable) {
                    this.EnsureWritable();
                }
                this._rgu[0] = num;
            }
        }

Same methods

BigIntegerBuilder::Add ( BigIntegerBuilder &reg ) : void

Usage Example

        /// <summary>Adds the values of two specified <see cref="BigInteger" /> objects.</summary>
        /// <returns>The sum of <paramref name="left" /> and <paramref name="right" />.</returns>
        /// <param name="left">The first value to add.</param>
        /// <param name="right">The second value to add.</param>
        public static BigInteger operator +(BigInteger left, BigInteger right)
        {
            if (right.IsZero)
            {
                return(left);
            }

            if (left.IsZero)
            {
                return(right);
            }

            var signLeft  = 1;
            var signRight = 1;
            var regLeft   = new BigIntegerBuilder(left, ref signLeft);
            var regRight  = new BigIntegerBuilder(right, ref signRight);

            if (signLeft != signRight)
            {
                regLeft.Sub(ref signLeft, ref regRight);
            }
            else
            {
                regLeft.Add(ref regRight);
            }

            return(regLeft.GetInteger(signLeft));
        }
All Usage Examples Of System.Numerics.BigIntegerBuilder::Add