BooRunner.Tools.ClassicParser.Parse C# (CSharp) Метод

Parse() публичный Метод

Parses provided string representation of BigInteger object.
public Parse ( string value, int startIndex, int endIndex, uint numberBase, uint>.IDictionary charToDigits, uint digitsRes ) : uint
value string Number as string.
startIndex int Index inside string from which to start.
endIndex int Index inside string on which to end.
numberBase uint Number base.
charToDigits uint>.IDictionary Char->digit dictionary.
digitsRes uint Resulting digits.
Результат uint
        public override uint Parse(string value, int startIndex, int endIndex, uint numberBase, IDictionary<char, uint> charToDigits, uint[] digitsRes)
        {
            uint newLength = base.Parse(value, startIndex, endIndex, numberBase, charToDigits, digitsRes);

            // Maybe base method already parsed this number
            if (newLength != 0) return newLength;

            // Do parsing in big cycle
            ulong numberBaseLong = numberBase;
            ulong digit;
            for (int i = startIndex; i <= endIndex; ++i)
            {
                digit = StrRepHelper.GetDigit(charToDigits, value[i], numberBase);

                // Next multiply existing values by base and add this value to them
                if (newLength == 0)
                {
                    if (digit != 0)
                    {
                        digitsRes[0] = (uint)digit;
                        newLength = 1;
                    }
                }
                else
                {
                    for (uint j = 0; j < newLength; ++j)
                    {
                        digit += digitsRes[j] * numberBaseLong;
                        digitsRes[j] = (uint)digit;
                        digit >>= 32;
                    }
                    if (digit != 0)
                    {
                        digitsRes[newLength++] = (uint)digit;
                    }
                }
            }

            return newLength;
        }