Equal to calling parseInt(cs, 10).
@param cs
@return
@throws java.lang.NumberFormatException if input cannot be parsed to proper
int.
@see java.lang.Integer#parseInt(java.lang.String)
@see java.lang.Character#digit(int, int)
250
public static final int parseInt(CharSequence cs)
    {
        if (CharSequences.startsWith(cs, "0b"))
        {
            return parseInt(cs, 2, 2, cs.length());
        }
        if (CharSequences.startsWith(cs, "0x"))
        {
            return parseInt(cs, 16, 2, cs.length());
        }
        return parseInt(cs, 10);
    }
149853
protected Number parseInteger(String string) throws ParseException {
		try {
			return Long.valueOf(string);
		} catch (NumberFormatException e) {
			fail(INTEGER);
			return null;
		}
	}
900305
public static int parseInt(byte[] bytes, int from, int to) {
        int result = 0;
        for (int i = from; i < to && i < bytes.length; i++) {
            result *= 10;
            result += (bytes[i] - (byte) '0');
        }
        return result;
    }
189884
public static Integer parseInteger(String value) throws ParseException
   {
      Integer result = null;

      if (value.length() > 0 && value.indexOf(' ') == -1)
      {
         if (value.indexOf('.') == -1)
         {
            result = Integer.valueOf(value);
         }
         else
         {
            Number n = DatatypeConverter.parseDouble(value);
            result = Integer.valueOf(n.intValue());
         }
      }

      return result;
   }
810673
public static Integer parse(final String s) {
        try {
            return Integer.parseInt(s);
        } catch (final NumberFormatException e) {
            return null;
        }
    }
869105
public static int parseInt(String s, final int start, final int end) throws NumberFormatException {
        return parseSignedInt(s, start, end);
    }
1285933
public static int string2int(String s, int radix)
        throws NumberFormatException {
        if (radix == 10) {
            return Integer.parseInt(s, radix);
        } else {
            char[] cs = s.toCharArray();
            int limit = Integer.MAX_VALUE / (radix/2);
            int n = 0;
            for (int i = 0; i < cs.length; i++) {
                int d = Character.digit(cs[i], radix);
                if (n < 0 ||
                    n > limit ||
                    n * radix > Integer.MAX_VALUE - d)
                    throw new NumberFormatException();
                n = n * radix + d;
            }
            return n;
        }
    }
699352
public void parseNumbers() {
        for (int i = '0'; i <= '9'; i++) {
            tokenTypes[i] |= TOKEN_DIGIT;
        }
        tokenTypes['.'] |= TOKEN_DIGIT;
        tokenTypes['-'] |= TOKEN_DIGIT;
    }
1159141
private int parseInteger(String value, int defaultValue)
	{
		try
		{
			return Integer.parseInt(value);
		}
		catch (NumberFormatException e)
		{
			return defaultValue;
		}
	}
599409
private Number consumeTokenNumber(char c) throws JsonParserException {
    int start = index - 1;
    int end = index;

    boolean isDouble = false;
    while (isDigitCharacter(peekChar())) {
      char next = (char)advanceChar();
      isDouble = next == '.' || next == 'e' || next == 'E' || isDouble;
      end++;
    }

    String number = string.substring(start, end);

    try {
      if (isDouble) {
        // Special zero handling to match JSON spec. Leading zero is only allowed if next character is . or e
        if (number.charAt(0) == '0') {
          if (number.charAt(1) == '.') {
            if (number.length() == 2)
              throw createParseException(null, "Malformed number: " + number, true);
          } else if (number.charAt(1) != 'e' && number.charAt(1) != 'E')
            throw createParseException(null, "Malformed number: " + number, true);
        }
        if (number.charAt(0) == '-') {
          if (number.charAt(1) == '0') {
            if (number.charAt(2) == '.') {
              if (number.length() == 3)
                throw createParseException(null, "Malformed number: " + number, true);
            } else if (number.charAt(2) != 'e' && number.charAt(2) != 'E')
              throw createParseException(null, "Malformed number: " + number, true);
          } else if (number.charAt(1) == '.') {
            throw createParseException(null, "Malformed number: " + number, true);
          }
        }

        return Double.parseDouble(number);
      }

      // Special zero handling to match JSON spec. No leading zeros allowed for integers.
      if (number.charAt(0) == '0') {
        if (number.length() == 1)
          return 0;
        throw createParseException(null, "Malformed number: " + number, true);
      }
      if (number.length() > 1 && number.charAt(0) == '-' && number.charAt(1) == '0') {
        if (number.length() == 2)
          return -0.0;
        throw createParseException(null, "Malformed number: " + number, true);
      }

      // HACK: Attempt to parse using the approximate best type for this
      int length = number.charAt(0) == '-' ? number.length() - 1 : number.length();
      if (length < 10) // 2 147 483 647
        return Integer.parseInt(number);
      if (length < 19) // 9 223 372 036 854 775 807
        return Long.parseLong(number);
      return new BigInteger(number);
    } catch (NumberFormatException e) {
      throw createParseException(e, "Malformed number: " + number, true);
    }
  }
320426
public static final int parseInt(String value, int defValue, String errorMsgOnParseFailure) {
      if (StringHelper.isEmpty(value)) {
         return defValue;
      } else {
         return parseInt(value, errorMsgOnParseFailure);
      }
   }
747484
public static final double findDouble(CharSequence cs, int beginIndex, int endIndex)
    {
        int begin = CharSequences.indexOf(cs, Primitives::isFloatDigit, beginIndex);
        int end = CharSequences.indexOf(cs, (c)->!Primitives.isFloatDigit(c), begin);
        return parseDouble(cs, begin, endIndex(end, endIndex));
    }
585965
public static double toNumber(String s) {
        final int len = s.length();

        // Skip whitespace at the start
        int start = 0;
        char startChar;
        for (;;) {
            if (start == len) {
                // empty or contains only whitespace
                return +0.0;
            }
            startChar = s.charAt(start);
            if (!ScriptRuntime.isStrWhiteSpaceChar(startChar)) {
                // found first non-whitespace character
                break;
            }
            start++;
        }

        // Skip whitespace at the end
        int end = len - 1;
        char endChar;
        while (ScriptRuntime.isStrWhiteSpaceChar(endChar = s.charAt(end))) {
            end--;
        }

        // Do not break scripts relying on old non-compliant conversion
        // (see bug #368)
        // 1. makes ToNumber parse only a valid prefix in hex literals (similar to 'parseInt()')
        //    ToNumber('0x10 something') => 16
        // 2. allows plus and minus signs for hexadecimal numbers
        //    ToNumber('-0x10') => -16
        // 3. disables support for binary ('0b10') and octal ('0o13') literals
        //    ToNumber('0b1') => NaN
        //    ToNumber('0o5') => NaN
        final Context cx = Context.getCurrentContext();
        final boolean oldParsingMode =
                cx == null || cx.getLanguageVersion() < Context.VERSION_ES6;

        // Handle non-base10 numbers
        if (startChar == '0') {
            if (start + 2 <= end) {
                final char radixC = s.charAt(start + 1);
                int radix = -1;
                if (radixC == 'x' || radixC == 'X') {
                    radix = 16;
                } else if (!oldParsingMode && (radixC == 'o' || radixC == 'O')) {
                    radix = 8;
                } else if (!oldParsingMode && (radixC == 'b' || radixC == 'B')) {
                    radix = 2;
                }
                if (radix != -1) {
                    if (oldParsingMode) {
                        return stringPrefixToNumber(s, start + 2, radix);
                    }
                    return stringToNumber(s, start + 2, end, radix);
                }
            }
        } else if (oldParsingMode && (startChar == '+' || startChar == '-')) {
            // If in old parsing mode, check for a signed hexadecimal number
            if (start + 3 <= end && s.charAt(start + 1) == '0') {
                final char radixC = s.charAt(start + 2);
                if (radixC == 'x' || radixC == 'X') {
                    double val = stringPrefixToNumber(s, start + 3, 16);
                    return startChar == '-' ? -val : val;
                }
            }
        }

        if (endChar == 'y') {
            // check for "Infinity"
            if (startChar == '+' || startChar == '-') {
                start++;
            }
            if (start + 7 == end && s.regionMatches(start, "Infinity", 0, 8)) {
                return startChar == '-'
                        ? Double.NEGATIVE_INFINITY
                        : Double.POSITIVE_INFINITY;
            }
            return NaN;
        }
        // A base10, non-infinity number:
        // just try a normal floating point conversion
        String sub = s.substring(start, end+1);
        // Quick test to check string contains only valid characters because
        // Double.parseDouble() can be slow and accept input we want to reject
        for (int i = sub.length() - 1; i >= 0; i--) {
            char c = sub.charAt(i);
            if (('0' <= c && c <= '9') || c == '.' ||
                    c == 'e' || c == 'E'  ||
                    c == '+' || c == '-')
                continue;
            return NaN;
        }
        try {
            return Double.parseDouble(sub);
        } catch (NumberFormatException ex) {
            return NaN;
        }
    }
765553
function parseNumber(num) {
    var numStr = Math.abs(num) + '';
    var exponent = 0, digits, integerLen;
    var i, j, zeros;
    // Decimal point?
    if ((integerLen = numStr.indexOf(DECIMAL_SEP)) > -1) {
        numStr = numStr.replace(DECIMAL_SEP, '');
    }
    // Exponential form?
    if ((i = numStr.search(/e/i)) > 0) {
        // Work out the exponent.
        if (integerLen < 0)
            integerLen = i;
        integerLen += +numStr.slice(i + 1);
        numStr = numStr.substring(0, i);
    }
    else if (integerLen < 0) {
        // There was no decimal point or exponent so it is an integer.
        integerLen = numStr.length;
    }
    // Count the number of leading zeros.
    for (i = 0; numStr.charAt(i) === ZERO_CHAR; i++) { /* empty */
    }
    if (i === (zeros = numStr.length)) {
        // The digits are all zero.
        digits = [0];
        integerLen = 1;
    }
    else {
        // Count the number of trailing zeros
        zeros--;
        while (numStr.charAt(zeros) === ZERO_CHAR)
            zeros--;
        // Trailing zeros are insignificant so ignore them
        integerLen -= i;
        digits = [];
        // Convert string to array of digits without leading/trailing zeros.
        for (j = 0; i <= zeros; i++, j++) {
            digits[j] = Number(numStr.charAt(i));
        }
    }
    // If the number overflows the maximum allowed digits then use an exponent.
    if (integerLen > MAX_DIGITS) {
        digits = digits.splice(0, MAX_DIGITS - 1);
        exponent = integerLen - 1;
        integerLen = 1;
    }
    return { digits: digits, exponent: exponent, integerLen: integerLen };
}
89993
public static int digit(char c, int radix) {
        for (int i = 0; i < MAX_RADIX && i < radix; i++) {
            if (digits[i] == c) {
                return i;
            }
        }
        return -1;
    }
280719
double string2Fraction(CharSequence cs, int readed) {
		if (cs.length() > 16) {
			throw new JsonParseException("Number string is too long.", readed);
		}
		double d = 0.0;
		for (int i = 0; i < cs.length(); i++) {
			int n = cs.charAt(i) - '0';
			d = d + (n == 0 ? 0 : n / Math.pow(10, i + 1));
		}
		return d;
	}
646537
public static int hex2bin(char c)
    {
        if (c >= '0' && c <= '9')
        {
            return (c - '0');
        }
        if (c >= 'A' && c <= 'F')
        {
            return (c - 'A' + 10);
        }
        if (c >= 'a' && c <= 'f')
        {
            return (c - 'a' + 10);
        }
        throw new IllegalArgumentException(
                "Input string may only contain hex digits, but found '" + c
                        + "'");
    }