Although (int) -1 == (long) -1, Integer.toXString produces a shorter result than
Long.toXString should.
*/
public static String toBinaryString(long v) {
int i = (int) v;
- if (i == v) {
+ if (v >= 0 && i == v) {
return Integer.toBinaryString(i);
}
*/
public static String toHexString(long v) {
int i = (int) v;
- if (i == v) {
+ if (v >= 0 && i == v) {
return Integer.toHexString(i);
}
*/
public static String toOctalString(long v) {
int i = (int) v;
- if (i == v) {
+ if (v >= 0 && i == v) {
return Integer.toOctalString(i);
}
int bufLen = 22; // Max number of octal digits in a long