Here you can find the source of unsignedIntToString(int x, int radix)
Parameter | Description |
---|---|
x | the value to convert to a string. |
radix | the radix to use while working with x |
Parameter | Description |
---|---|
IllegalArgumentException | if radix is not between Character#MIN_RADIX and Character#MAX_RADIX. |
private static String unsignedIntToString(int x, int radix)
//package com.java2s; //Licensed under the Apache License, Version 2.0 (the "License"); public class Main { static final long INT_MASK = 0xffffffffL; /**/* w w w.j av a 2 s .c o m*/ * Returns a string representation of x, where x is treated as unsigned. */ public static String unsignedIntToString(int x) { return unsignedIntToString(x, 10); } /** * Returns a string representation of {@code x} for the given radix, where {@code x} is treated as unsigned. * * @param x * the value to convert to a string. * @param radix * the radix to use while working with {@code x} * @throws IllegalArgumentException * if {@code radix} is not between {@link Character#MIN_RADIX} and {@link Character#MAX_RADIX}. */ private static String unsignedIntToString(int x, int radix) { long asLong = x & INT_MASK; return Long.toString(asLong, radix); } }