Jurassic.BigInteger.Parse C# (CSharp) Method

Parse() public static method

Converts the string representation of a number to its BigInteger equivalent.
public static Parse ( string str ) : BigInteger
str string A string that contains the number to convert.
return BigInteger
        public static BigInteger Parse(string str)
        {
            BigInteger result = BigInteger.Zero;
            bool negative = false;
            int i = 0;
            if (str[0] == '-')
            {
                negative = true;
                i = 1;
            }
            else if (str[0] == '+')
                i = 1;
            for (; i < str.Length; i++)
            {
                char c = str[i];
                if (c < '0' || c > '9')
                    throw new FormatException("Invalid character in number.");
                result = MultiplyAdd(result, 10, c - '0');
            }
            if (result.wordCount != 1 || result.bits[0] != 0)
                result.sign = negative == true ? -1 : 1;
            return result;
        }