Exemple #1
0
        public void Multiply(BigIntWithUnit elem2)
        {
            if (this == 0 || elem2 == 0)
            {
                Sub(this);
                return;
            }
            if (elem2 == 1)
            {
                return;
            }
            if (this == 1)
            {
                Sub(this);
                Add(elem2);
                return;
            }

            BigIntWithUnit Result     = 0;
            BigIntWithUnit SemiResult = elem2 * _intArray[0];

            SemiResult.ShiftRight(3);
            Result.Add(SemiResult);
            for (int i = 1; i < _intArray.Count; i++)
            {
                SemiResult = elem2 * _intArray[i];
                SemiResult.ShiftLeft((i - 1) * 3);
                Result.Add(SemiResult);
            }
            //There is no this set function :(
            Sub(this);
            Add(Result);
        }
Exemple #2
0
        public static BigIntWithUnit operator +(BigIntWithUnit elem1, BigIntWithUnit elem2)
        {
            BigIntWithUnit result = new BigIntWithUnit();

            result.Add(elem1);
            result.Add(elem2);
            return(result);
        }
Exemple #3
0
        public static BigIntWithUnit operator *(BigIntWithUnit elem1, float elem2)
        {
            BigIntWithUnit result = new BigIntWithUnit();

            result.Add(elem1);
            result.Multiply(elem2, 2);
            return(result);
        }
Exemple #4
0
        public static BigIntWithUnit operator *(BigIntWithUnit elem1, BigIntWithUnit elem2)
        {
            BigIntWithUnit result = 0;

            result.Add(elem1);
            result.Multiply(elem2);
            return(result);
        }
Exemple #5
0
        /// <summary>
        /// Calculates elem1 * elem2/100
        /// </summary>
        /// <param name="elem1"></param>
        /// <param name="elem2"></param>
        /// <returns></returns>
        public static BigIntWithUnit MultiplyPercent(BigIntWithUnit elem1, double elem2)
        {
            var result = new BigIntWithUnit();

            if (elem2 < 100)
            {
                return(result);
            }
            result.Add(elem1);
            result.IncreasePercent((int)elem2 - 100);
            return(result);
        }