/** Returns a string representation of the {@code UnsignedLong} value, in base 10. */ @Override public String toString() { return UnsignedLongs.toString(value); }
/** * Returns a string representation of the {@code UnsignedLong} 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 UnsignedLongs.toString(value, radix); } }
/** * Returns a string representation of x, where x is treated as unsigned. * * <p><b>Java 8 users:</b> use {@link Long#toUnsignedString(long)} instead. */ public static String toString(long x) { return toString(x, 10); }
/** * Returns a string representation of the {@code UnsignedLong} 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 UnsignedLongs.toString(value, radix); } }
/** Returns a string representation of the {@code UnsignedLong} value, in base 10. */ @Override public String toString() { return UnsignedLongs.toString(value); }
/** * Returns a string representation of x, where x is treated as unsigned. * * <p><b>Java 8 users:</b> use {@link Long#toUnsignedString(long)} instead. */ public static String toString(long x) { return toString(x, 10); }
/** Returns a string representation of the {@code UnsignedLong} value, in base 10. */ @Override public String toString() { return UnsignedLongs.toString(value); }
/** * Returns a string representation of x, where x is treated as unsigned. * * <p><b>Java 8 users:</b> use {@link Long#toUnsignedString(long)} instead. */ public static String toString(long x) { return toString(x, 10); }
/** * Returns a string representation of the {@code UnsignedLong} 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 UnsignedLongs.toString(value, radix); } }
/** * Returns a string containing the supplied unsigned {@code long} 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 long} values, possibly empty */ public static String join(String separator, long... 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 long} 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 long} values, possibly empty */ public static String join(String separator, long... 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 long} 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 long} values, possibly empty */ public static String join(String separator, long... 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() { String[] tests = { "0", "ffffffffffffffff", "7fffffffffffffff", "ff1a618b7f65ea12", "5a4316b8c153ac4d", "6cf78a4b139a4e2a" }; int[] bases = {2, 5, 7, 8, 10, 16}; for (int base : bases) { for (String x : tests) { BigInteger xValue = new BigInteger(x, 16); long xLong = xValue.longValue(); // signed assertEquals(xValue.toString(base), UnsignedLongs.toString(xLong, base)); } } }
public void testAsUnsignedBigIntegerValue() { for (long value : TEST_LONGS) { BigInteger expected = (value >= 0) ? BigInteger.valueOf(value) : BigInteger.valueOf(value).add(BigInteger.ZERO.setBit(64)); assertEquals( UnsignedLongs.toString(value), expected, UnsignedLong.fromLongBits(value).bigIntegerValue()); } }
public void testAsUnsignedAndLongValueAreInverses() { for (long value : TEST_LONGS) { assertEquals( UnsignedLongs.toString(value), value, UnsignedLong.fromLongBits(value).longValue()); } }
/** * Returns this span id formatted as an unsigned long integer. * * @return The span identifier formatted for API consumption. */ public String getApiString() { return UnsignedLongs.toString(spanId); } }
/** * Returns a string representation of the {@code UnsignedLong} value, in base 10. */ @Override public String toString() { return UnsignedLongs.toString(value); }
/** * Converts a long value to hex string; 16 wide and sans 0x. * * @param value long value * @return hex string */ public static String toHex(long value) { return Strings.padStart(UnsignedLongs.toString(value, 16), 16, '0'); }
/** * Converts a long value to hex string; 16 wide and sans 0x. * * @param value long value * @param width string width; zero padded * @return hex string */ public static String toHex(long value, int width) { return Strings.padStart(UnsignedLongs.toString(value, 16), width, '0'); }
@Override public String toString() { return "@" + UnsignedLongs.toString(longValue()); } }