src/NeinMath/IntegerConverter.cs
/// <summary>
/// Returns an Integer converted from a decimal string.
/// </summary>
/// <param name="value">A decimal string.</param>
/// <returns>An Integer formed by a decimal string.</returns>
Returns an Integer converted from a decimal string.
Returns an Integer converted from a decimal string .
public static Integer FromDecimalString(string value)
        {
            if (value == null)
                throw new ArgumentNullException(nameof(value));
            if (value.Length == 0)
                throw new ArgumentOutOfRangeException(nameof(value));
            var sign = value[0] == '-';
            if (sign)
                value = value.Substring(1);
            var result = default(uint[]);
            var resultLength = 0;
            while (value.Length > 0)
            {
                var length = value.Length < 9 ? value.Length : 9;
                var chunk = value.Substring(0, length);
                result = Calc.Multiply(result, resultLength,
                    (uint)Math.Pow(10, length));
                resultLength = Bits.Length(result, result.Length);
                result = Calc.Add(result, resultLength,
                    uint.Parse(chunk, NumberStyles.None,
                    CultureInfo.InvariantCulture));
                resultLength = Bits.Length(result, result.Length);
                value = value.Substring(length);
            }
            return new Integer(result, resultLength, sign);
        }
public static Integer FromDecimalString ( string value ) { if ( value == null ) throw new ArgumentNullException ( nameof ( value ) ) ; if ( value . Length == 0 ) throw new ArgumentOutOfRangeException ( nameof ( value ) ) ; var sign = value [ 0 ] == ' ' ; if ( sign ) value = value . Substring ( 1 ) ; var result = default ( uint [ ] ) ; var resultLength = 0 ; while ( value . Length > 0 ) { var length = value . Length < 9 ? value . Length : 9 ; var chunk = value . Substring ( 0 , length ) ; result = Calc . Multiply ( result , resultLength , ( uint ) Math . Pow ( 10 , length ) ) ; resultLength = Bits . Length ( result , result . Length ) ; result = Calc . Add ( result , resultLength , uint . Parse ( chunk , NumberStyles . None , CultureInfo . InvariantCulture ) ) ; resultLength = Bits . Length ( result , result . Length ) ; value = value . Substring ( length ) ; } return new Integer ( result , resultLength , sign ) ; }
Returns an Integer converted from a decimal string.
Returns an Integer converted from a decimal string .
An Integer formed by a decimal string.
An Integer formed by a decimal string .
value
string
A decimal string.
A decimal string .