/** * Returns a string representation of x, where x is treated as unsigned. * * <p><b>Java 8 users:</b> use {@link Integer#toUnsignedString(int)} instead. */ public static String toString(int x) { return toString(x, 10); }
/** * Returns a string representation of the {@code UnsignedInteger} value, in base {@code radix}. If * {@code radix < Character.MIN_RADIX} or {@code radix > Character.MAX_RADIX}, the radix {@code * 10} is used. */ public String toString(int radix) { return UnsignedInts.toString(value, radix); } }
/** * Returns a string representation of x, where x is treated as unsigned. * * <p><b>Java 8 users:</b> use {@link Integer#toUnsignedString(int)} instead. */ public static String toString(int x) { return toString(x, 10); }
/** * Returns a string representation of the {@code UnsignedInteger} value, in base {@code radix}. If * {@code radix < Character.MIN_RADIX} or {@code radix > Character.MAX_RADIX}, the radix {@code * 10} is used. */ public String toString(int radix) { return UnsignedInts.toString(value, radix); } }
/** * Returns a string representation of x, where x is treated as unsigned. * * <p><b>Java 8 users:</b> use {@link Integer#toUnsignedString(int)} instead. */ public static String toString(int x) { return toString(x, 10); }
/** * Returns a string representation of the {@code UnsignedInteger} value, in base {@code radix}. If * {@code radix < Character.MIN_RADIX} or {@code radix > Character.MAX_RADIX}, the radix {@code * 10} is used. */ public String toString(int radix) { return UnsignedInts.toString(value, radix); } }
/** * Returns a string containing the supplied unsigned {@code int} values separated by {@code * separator}. For example, {@code join("-", 1, 2, 3)} returns the string {@code "1-2-3"}. * * @param separator the text that should appear between consecutive values in the resulting string * (but not at the start or end) * @param array an array of unsigned {@code int} values, possibly empty */ public static String join(String separator, int... array) { checkNotNull(separator); if (array.length == 0) { return ""; } // For pre-sizing a builder, just get the right order of magnitude StringBuilder builder = new StringBuilder(array.length * 5); builder.append(toString(array[0])); for (int i = 1; i < array.length; i++) { builder.append(separator).append(toString(array[i])); } return builder.toString(); }
/** * Returns a string containing the supplied unsigned {@code int} values separated by {@code * separator}. For example, {@code join("-", 1, 2, 3)} returns the string {@code "1-2-3"}. * * @param separator the text that should appear between consecutive values in the resulting string * (but not at the start or end) * @param array an array of unsigned {@code int} values, possibly empty */ public static String join(String separator, int... array) { checkNotNull(separator); if (array.length == 0) { return ""; } // For pre-sizing a builder, just get the right order of magnitude StringBuilder builder = new StringBuilder(array.length * 5); builder.append(toString(array[0])); for (int i = 1; i < array.length; i++) { builder.append(separator).append(toString(array[i])); } return builder.toString(); }
/** * Returns a string containing the supplied unsigned {@code int} values separated by {@code * separator}. For example, {@code join("-", 1, 2, 3)} returns the string {@code "1-2-3"}. * * @param separator the text that should appear between consecutive values in the resulting string * (but not at the start or end) * @param array an array of unsigned {@code int} values, possibly empty */ public static String join(String separator, int... array) { checkNotNull(separator); if (array.length == 0) { return ""; } // For pre-sizing a builder, just get the right order of magnitude StringBuilder builder = new StringBuilder(array.length * 5); builder.append(toString(array[0])); for (int i = 1; i < array.length; i++) { builder.append(separator).append(toString(array[i])); } return builder.toString(); }
public void testToString() { int[] bases = {2, 5, 7, 8, 10, 16}; for (long a : UNSIGNED_INTS) { for (int base : bases) { assertEquals(UnsignedInts.toString((int) a, base), Long.toString(a, base)); } } }
public void testFromIntBitsAndIntValueAreInverses() { for (int value : TEST_INTS) { assertEquals( UnsignedInts.toString(value), value, UnsignedInteger.fromIntBits(value).intValue()); } }
public void testFromIntBitsLongValue() { for (int value : TEST_INTS) { long expected = value & 0xffffffffL; assertEquals( UnsignedInts.toString(value), expected, UnsignedInteger.fromIntBits(value).longValue()); } }
/** * Returns a string representation of x, where x is treated as unsigned. */ public static String toString(int x) { return toString(x, 10); }
/** * Returns a string representation of the {@code UnsignedInteger} value, in base {@code radix}. * If {@code radix < Character.MIN_RADIX} or {@code radix > Character.MAX_RADIX}, the radix * {@code 10} is used. */ public String toString(int radix) { return UnsignedInts.toString(value, radix); } }
/** * Returns a string representation of the {@code UnsignedInteger} value, in base {@code radix}. * If {@code radix < Character.MIN_RADIX} or {@code radix > Character.MAX_RADIX}, the radix * {@code 10} is used. */ public String toString(int radix) { return UnsignedInts.toString(value, radix); } }
/** * Returns a string representation of the {@code UnsignedInteger} value, in base {@code radix}. If * {@code radix < Character.MIN_RADIX} or {@code radix > Character.MAX_RADIX}, the radix {@code * 10} is used. */ public String toString(int radix) { return UnsignedInts.toString(value, radix); } }
/** * Returns a string representation of the {@code UnsignedInteger} value, in base {@code radix}. If * {@code radix < Character.MIN_RADIX} or {@code radix > Character.MAX_RADIX}, the radix {@code * 10} is used. */ public String toString(int radix) { return UnsignedInts.toString(value, radix); } }
/** * Returns a string representation of x, where x is treated as unsigned. */ public static String toString(int x) { return toString(x, 10); }
/** * Returns a string representation of x, where x is treated as unsigned. * * <p><b>Java 8 users:</b> use {@link Integer#toUnsignedString(int)} instead. */ public static String toString(int x) { return toString(x, 10); }
public void testToString() { int[] bases = {2, 5, 7, 8, 10, 16}; for (long a : UNSIGNED_INTS) { for (int base : bases) { assertEquals(UnsignedInts.toString((int) a, base), Long.toString(a, base)); } } }