private static BigPointNumber Multiply(BigPointNumber a, BigPointNumber b)
        {
            var retValue = Zero;

            for (var i = 0; i < a.Size; i++)
            {
                for (int j = 0, carry = 0; (j < b.Size) || (carry > 0); j++)
                {
                    var cur = retValue.GetByte(i + j) + a.GetByte(i) * b.GetByte(j) + carry;
                    retValue.SetByte(i + j, (byte)(cur % 10));
                    carry = cur / 10;
                }
            }

            retValue.Sign = a.Sign == b.Sign ? Sign.Plus : Sign.Minus;
            int delta = 0;

            delta += a.PointPosition != -1 ? a.SizeAfterPoint : 0;
            delta += b.PointPosition != -1 ? b.SizeAfterPoint : 0;
            retValue.PointPosition = retValue.digits.Count - delta;
            if (retValue.PointPosition == retValue.digits.Count)
            {
                retValue.PointPosition = -1;
            }
            retValue.RemoveNulls();
            return(retValue);
        }
        private static BigPointNumber Substract(BigPointNumber a, BigPointNumber b)
        {
            BigPointNumber tmp_a = a;
            BigPointNumber tmp_b = b;


            var digits = new List <byte>();

            BigPointNumber max = Zero;
            BigPointNumber min = Zero;

            //сравниваем числа игнорируя знак
            var compare = Comparison(tmp_a, tmp_b, ignoreSign: true);

            switch (compare)
            {
            case -1:
                min = tmp_a;
                max = tmp_b;
                break;

            case 0:
                //если числа равны возвращаем 0
                return(Zero);

            case 1:
                min = tmp_b;
                max = tmp_a;
                break;
            }

            //из большего вычитаем меньшее
            EqualizationDigitsCount(ref tmp_a, ref tmp_b);

            var t = 0;

            for (var i = 0; i < tmp_a.Size; i++)
            {
                var s = max.GetByte(i) - min.GetByte(i) - t;
                if (s < 0)
                {
                    s += 10;
                    t  = 1;
                }
                else
                {
                    t = 0;
                }

                digits.Add((byte)s);
            }
            int            tmp_PointPos = tmp_a.PointPosition > tmp_b.PointPosition ? tmp_a.PointPosition : tmp_b.PointPosition;
            BigPointNumber result       = new BigPointNumber(digits, max.Sign, tmp_PointPos);

            result.RemoveNulls();
            return(new BigPointNumber(digits, max.Sign, tmp_PointPos));
        }
        private static int CompareDigits(BigPointNumber a, BigPointNumber b)
        {
            BigPointNumber tmp_a = a;
            BigPointNumber tmp_b = b;

            EqualizationDigitsCount(ref tmp_a, ref tmp_b);

            for (var i = tmp_a.Size; i >= 0; i--)
            {
                if (tmp_a.GetByte(i) < tmp_b.GetByte(i))
                {
                    return(-1);
                }
                else if (tmp_a.GetByte(i) > tmp_b.GetByte(i))
                {
                    return(1);
                }
            }

            return(0);
        }
        private static BigPointNumber Add(BigPointNumber a, BigPointNumber b)
        {
            BigPointNumber tmp_a = a;
            BigPointNumber tmp_b = b;

            EqualizationDigitsCount(ref tmp_a, ref tmp_b);

            var digits = new List <byte>();

            byte t = 0;

            for (int i = 0; i < tmp_a.Size; i++)
            {
                byte sum = (byte)(a.GetByte(i) + b.GetByte(i) + t);
                if (sum > 10)
                {
                    sum -= 10;
                    t    = 1;
                }
                else
                {
                    t = 0;
                }

                digits.Add(sum);
            }

            if (t > 0)
            {
                digits.Add(t);
            }

            int tmp_PointPos = tmp_a.PointPosition > tmp_b.PointPosition ? tmp_a.PointPosition : tmp_b.PointPosition;

            return(new BigPointNumber(digits, tmp_a.Sign, tmp_PointPos));
        }