docs: public static long parseLong(final CharSequence s) {
      final int n = s.length();  // Will NPE if necessary.
      if (n == 0) {
        throw new NumberFormatException("Empty string");
      }
      char c = s.charAt(0);  // Current character.
      int i = 1;  // index in `s'.
      if (c < '0' && (c == '+' || c == '-')) {  // Only 1 test in common case.
        if (n == 1) {
          throw new NumberFormatException("Just a sign, no value: " + s);
        } else if (n > 20) {  // "+9223372036854775807" or "-9223372036854775808"
            throw new NumberFormatException("Value too long: " + s);
        }
        c = s.charAt(1);
        i = 2;  // Skip over the sign.
      } else if (n > 19) {  // "9223372036854775807"
        throw new NumberFormatException("Value too long: " + s);
      }
      long v = 0;  // The result (negated to easily handle MIN_VALUE).
      do {
        if ('0' <= c && c <= '9') {
          v -= c - '0';
        } else {
          throw new NumberFormatException("Invalid character '" + c
                                          + "' in " + s);
        }
        if (i == n) {
          break;
        }
        v *= 10;
        c = s.charAt(i++);
      } while (true);
      if (v > 0) {
        throw new NumberFormatException("Overflow in " + s);
      } else if (s.charAt(0) == '-') {
        return v;  // Value is already negative, return unchanged.
      } else if (v == Long.MIN_VALUE) {
        throw new NumberFormatException("Overflow in " + s);
      } else {
        return -v;  // Positive value, need to fix the sign.
      }
    }