/** * Returns a {@code String} object representing the specified * {@code long}. The argument is converted to signed decimal * representation and returned as a string, exactly as if the * argument and the radix 10 were given as arguments to the {@link * #toString(long, int)} method. * * @param i a {@code long} to be converted. * @return a string representation of the argument in base 10. */ public static String toString(long i) { if (i == Long.MIN_VALUE) return "-9223372036854775808"; int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i); char[] buf = new char[size]; getChars(i, size, buf); return new String(buf, 0, size).toString(); }
/** * Returns a {@code String} object representing the specified * {@code long}. The argument is converted to signed decimal * representation and returned as a string, exactly as if the * argument and the radix 10 were given as arguments to the {@link * #toString(long, int)} method. * * @param i a {@code long} to be converted. * @return a string representation of the argument in base 10. */ public static String toString(long i) { if (i == Long.MIN_VALUE) return "-9223372036854775808"; int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i); char[] buf = new char[size]; getChars(i, size, buf); return new String(buf, 0, size).toString(); }
/** * Appends the string representation of the {@code long} * argument to this sequence. * <p> * The overall effect is exactly as if the argument were converted * to a string by the method {@link String#valueOf(long)}, * and the characters of that string were then * {@link #append(String) appended} to this character sequence. * * @param l a {@code long}. * @return a reference to this object. */ public AbstractStringBuilder append(long l) { if (l == Long.MIN_VALUE) { append("-9223372036854775808"); return this; } int appendedLength = (l < 0) ? Long.stringSize(-l) + 1 : Long.stringSize(l); int spaceNeeded = count + appendedLength; ensureCapacityInternal(spaceNeeded); Long.getChars(l, spaceNeeded, value); count = spaceNeeded; return this; }
/** * Appends the string representation of the {@code long} * argument to this sequence. * <p> * The overall effect is exactly as if the argument were converted * to a string by the method {@link String#valueOf(long)}, * and the characters of that string were then * {@link #append(String) appended} to this character sequence. * * @param l a {@code long}. * @return a reference to this object. */ public AbstractStringBuilder append(long l) { if (l == Long.MIN_VALUE) { append("-9223372036854775808"); return this; } int appendedLength = (l < 0) ? Long.stringSize(-l) + 1 : Long.stringSize(l); int spaceNeeded = count + appendedLength; ensureCapacityInternal(spaceNeeded); Long.getChars(l, spaceNeeded, value); count = spaceNeeded; return this; }