< prev index next >

src/java.base/share/classes/java/lang/Long.java

Print this page

        

*** 396,436 **** return new String(buf, UTF16); } } /** ! * Format a long (treated as unsigned) into a byte buffer (LATIN1 version). If * {@code len} exceeds the formatted ASCII representation of {@code val}, * {@code buf} will be padded with leading zeroes. * * @param val the unsigned long to format * @param shift the log2 of the base to format in (4 for hex, 3 for octal, 1 for binary) ! * @param buf the byte buffer to write to * @param offset the offset in the destination buffer to start at * @param len the number of characters to write */ ! private static void formatUnsignedLong0(long val, int shift, byte[] buf, int offset, int len) { int charPos = offset + len; int radix = 1 << shift; int mask = radix - 1; do { buf[--charPos] = (byte)Integer.digits[((int) val) & mask]; val >>>= shift; } while (charPos > offset); } ! /** ! * Format a long (treated as unsigned) into a byte buffer (UTF16 version). If ! * {@code len} exceeds the formatted ASCII representation of {@code val}, ! * {@code buf} will be padded with leading zeroes. ! * ! * @param val the unsigned long to format ! * @param shift the log2 of the base to format in (4 for hex, 3 for octal, 1 for binary) ! * @param buf the byte buffer to write to ! * @param offset the offset in the destination buffer to start at ! * @param len the number of characters to write ! */ private static void formatUnsignedLong0UTF16(long val, int shift, byte[] buf, int offset, int len) { int charPos = offset + len; int radix = 1 << shift; int mask = radix - 1; do { --- 396,428 ---- return new String(buf, UTF16); } } /** ! * Format a long (treated as unsigned) into a character buffer. If * {@code len} exceeds the formatted ASCII representation of {@code val}, * {@code buf} will be padded with leading zeroes. * * @param val the unsigned long to format * @param shift the log2 of the base to format in (4 for hex, 3 for octal, 1 for binary) ! * @param buf the character buffer to write to * @param offset the offset in the destination buffer to start at * @param len the number of characters to write */ ! ! /** byte[]/LATIN1 version */ ! static void formatUnsignedLong0(long val, int shift, byte[] buf, int offset, int len) { int charPos = offset + len; int radix = 1 << shift; int mask = radix - 1; do { buf[--charPos] = (byte)Integer.digits[((int) val) & mask]; val >>>= shift; } while (charPos > offset); } ! /** byte[]/UTF16 version */ private static void formatUnsignedLong0UTF16(long val, int shift, byte[] buf, int offset, int len) { int charPos = offset + len; int radix = 1 << shift; int mask = radix - 1; do {
*** 745,755 **** * {@link java.lang.Character#MAX_RADIX}. * @since 9 */ public static long parseLong(CharSequence s, int beginIndex, int endIndex, int radix) throws NumberFormatException { ! Objects.requireNonNull(s); if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) { throw new IndexOutOfBoundsException(); } if (radix < Character.MIN_RADIX) { --- 737,747 ---- * {@link java.lang.Character#MAX_RADIX}. * @since 9 */ public static long parseLong(CharSequence s, int beginIndex, int endIndex, int radix) throws NumberFormatException { ! s = Objects.requireNonNull(s); if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) { throw new IndexOutOfBoundsException(); } if (radix < Character.MIN_RADIX) {
*** 991,1001 **** * {@link java.lang.Character#MAX_RADIX}. * @since 9 */ public static long parseUnsignedLong(CharSequence s, int beginIndex, int endIndex, int radix) throws NumberFormatException { ! Objects.requireNonNull(s); if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) { throw new IndexOutOfBoundsException(); } int start = beginIndex, len = endIndex - beginIndex; --- 983,993 ---- * {@link java.lang.Character#MAX_RADIX}. * @since 9 */ public static long parseUnsignedLong(CharSequence s, int beginIndex, int endIndex, int radix) throws NumberFormatException { ! s = Objects.requireNonNull(s); if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length()) { throw new IndexOutOfBoundsException(); } int start = beginIndex, len = endIndex - beginIndex;
< prev index next >