public class IntegerFormatting extends Object
| Constructor and Description |
|---|
IntegerFormatting()
|
| Modifier and Type | Method and Description |
|---|---|
static String |
intToBinaryString(int i)
Returns a string representation of the integer argument as an unsigned integer in base 2.
|
static String |
intToHexString(int i, Case
Returns a string representation of the integer argument as an unsigned integer in base 16.
|
static String |
intToOctalString(int i)
Returns a string representation of the integer argument as an unsigned integer in base 8.
|
static String |
longToBinaryString(long i)
Returns a string representation of the
long argument as an unsigned integer in base 2.
|
static String |
longToHexString(long i, Case
Returns a string representation of the
long argument as an unsigned integer in base 16.
|
static String |
longToOctalString(long i)
Returns a string representation of the
long argument as an unsigned integer in base 8.
|
public static StringintToHexString(int i, Case c)
The unsigned integer value is the argument plus 232 if the argument is negative; otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in hexadecimal (base 16) with no extra leading 0s. If the unsigned magnitude is zero, it is represented by a single zero character '0' ('\u0030'); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as hexadecimal digits:
0123456789abcdef
These are the characters
'\u0030' through
'\u0039' and
'\u0061' through
'\u0066'. If uppercase letters are desired, the
String.toUpperCase() method may be called on the result:
Integer.toHexString(n).toUpperCase()
i - an integer to be converted to a string.
public static StringintToOctalString(int i)
The unsigned integer value is the argument plus 232 if the argument is negative; otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in octal (base 8) with no extra leading 0s.
If the unsigned magnitude is zero, it is represented by a single zero character '0' ('\u0030'); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as octal digits:
01234567
These are the characters
'\u0030' through
'\u0037'.
i - an integer to be converted to a string.
public static StringintToBinaryString(int i)
The unsigned integer value is the argument plus 232 if the argument is negative; otherwise it is equal to the argument. This value is converted to a string of ASCII digits in binary (base 2) with no extra leading 0s. If the unsigned magnitude is zero, it is represented by a single zero character '0' ('\u0030'); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The characters '0' ('\u0030') and '1' ('\u0031') are used as binary digits.
i - an integer to be converted to a string.
public static StringlongToHexString(long i, Case c)
long argument as an unsigned integer in base 16.
The unsigned long value is the argument plus 264 if the argument is negative; otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in hexadecimal (base 16) with no extra leading 0s.
The value of the argument can be recovered from the returned string s by calling Long.parseUnsignedLong(s, 16).
If the unsigned magnitude is zero, it is represented by a single zero character '0' ('\u0030'); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as hexadecimal digits:
0123456789abcdef
These are the characters
'\u0030' through
'\u0039' and
'\u0061' through
'\u0066'. If uppercase letters are desired, the
String.toUpperCase() method may be called on the result:
Long.toHexString(n).toUpperCase()
i - a
long to be converted to a string.
long value represented by the argument in hexadecimal (base 16).
#parseUnsignedLong(String, int),
#longToUnsignedString(long, int)
public static StringlongToOctalString(long i)
long argument as an unsigned integer in base 8.
The unsigned long value is the argument plus 264 if the argument is negative; otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in octal (base 8) with no extra leading 0s.
The value of the argument can be recovered from the returned string s by calling Long.parseUnsignedLong(s, 8).
If the unsigned magnitude is zero, it is represented by a single zero character '0' ('\u0030'); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as octal digits:
01234567
These are the characters
'\u0030' through
'\u0037'.
i - a
long to be converted to a string.
long value represented by the argument in octal (base 8).
#parseUnsignedLong(String, int),
#longToUnsignedString(long, int)
public static StringlongToBinaryString(long i)
long argument as an unsigned integer in base 2.
The unsigned long value is the argument plus 264 if the argument is negative; otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in binary (base 2) with no extra leading 0s.
The value of the argument can be recovered from the returned string s by calling Long.parseUnsignedLong(s, 2).
If the unsigned magnitude is zero, it is represented by a single zero character '0' ('\u0030'); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The characters '0' ('\u0030') and '1' ('\u0031') are used as binary digits.
i - a
long to be converted to a string.
long value represented by the argument in binary (base 2).
#parseUnsignedLong(String, int),
#longToUnsignedString(long, int)