MCPcopy Index your code
hub / github.com/davidgiven/luje / parse

Method parse

lib/java/lang/Integer.java:352–377  ·  view source on GitHub ↗
(String string, int offset, int radix,
            boolean negative)

Source from the content-addressed store, hash-verified

350 }
351
352 private static int parse(String string, int offset, int radix,
353 boolean negative) throws NumberFormatException {
354 int max = Integer.MIN_VALUE / radix;
355 int result = 0, length = string.length();
356 while (offset < length) {
357 int digit = Character.digit(string.charAt(offset++), radix);
358 if (digit == -1) {
359 throw new NumberFormatException(string);
360 }
361 if (max > result) {
362 throw new NumberFormatException(string);
363 }
364 int next = result * radix - digit;
365 if (next > result) {
366 throw new NumberFormatException(string);
367 }
368 result = next;
369 }
370 if (!negative) {
371 result = -result;
372 if (result < 0) {
373 throw new NumberFormatException(string);
374 }
375 }
376 return result;
377 }
378
379 @Override
380 public short shortValue() {

Callers 2

decodeMethod · 0.95
parseIntMethod · 0.95

Calls 3

digitMethod · 0.95
lengthMethod · 0.65
charAtMethod · 0.65

Tested by

no test coverage detected