Utils { public static long parseLong(Charray chars, int base) { int offset = chars.offset; boolean negative = false; char firstChar = chars.charAt(0); if (firstChar == '-') { negative = true; offset += 1; } else if (firstChar == '+') { offset += 1; } long value = 0, coefficient = 1; char[] array = chars.chars; for (int i = chars.limit - 1; i >= offset; i--) { int digitValue = Character.digit(array[i], base); if (digitValue == -1) { throw new ParsingException("Invalid value: " + chars); } value += digitValue * coefficient; coefficient *= base; } return negative ? -value : value; } private  Utils(); static String positionToString(int line, int column); static boolean arrayContains(char[] array, char element); static int arrayIndexOf(char[] array, char element); static long parseLong(Charray chars, int base); static int parseInt(Charray chars, int base); static double parseDouble(Charray chars);  }
@Test void parseLong() { assertEquals(123456789L, Utils.parseLong(new Charray("123456789"), 10)); assertEquals(0, Utils.parseLong(new Charray("0"), 10)); assertEquals(-123456789L, Utils.parseLong(new Charray("-123456789"), 10)); assertEquals(0xff, Utils.parseLong(new Charray("ff"), 16)); }