MCPcopy Create free account
hub / github.com/davidgiven/luje / parse

Method parse

lib/java/lang/Long.java:344–369  ·  view source on GitHub ↗
(String string, int offset, int radix,
            boolean negative)

Source from the content-addressed store, hash-verified

342 }
343
344 private static long parse(String string, int offset, int radix,
345 boolean negative) {
346 long max = Long.MIN_VALUE / radix;
347 long result = 0, length = string.length();
348 while (offset < length) {
349 int digit = Character.digit(string.charAt(offset++), radix);
350 if (digit == -1) {
351 throw new NumberFormatException(string);
352 }
353 if (max > result) {
354 throw new NumberFormatException(string);
355 }
356 long next = result * radix - digit;
357 if (next > result) {
358 throw new NumberFormatException(string);
359 }
360 result = next;
361 }
362 if (!negative) {
363 result = -result;
364 if (result < 0) {
365 throw new NumberFormatException(string);
366 }
367 }
368 return result;
369 }
370
371 @Override
372 public short shortValue() {

Callers 2

decodeMethod · 0.95
parseLongMethod · 0.95

Calls 3

digitMethod · 0.95
lengthMethod · 0.65
charAtMethod · 0.65

Tested by

no test coverage detected