format. For example, Integer.toOctalString(10) returns "12".
Negative values are treated as described in toBinaryString. For
example, Integer.toOctalString(-10) returns "37777777766".
public static StringtoHexString(typeval)
Returns a string representation of the given value in an unsigned base 16
format. For example, Integer.toHexString(10) returns "a".
Negative values are treated as described in toBinaryString. For
example, Integer.toHexString(-10) returns "fffffff6".
Note that none of the string formats include information regarding the radix in that formatthere is no leading 0
for octal, or 0x for hexadecimal. If radix information is needed then you must construct it yourself.
The Short, Integer, and Long classes have a method reverseBytes that returns a value with its
constituent bytes in the reverse order to the value passed in. For example,
Integer.reverseBytes(0x0000ABCD) returns an int value with the hexadecimal representation of
0xCDAB0000. The Integer and Long classes also provide a family of bit-querying methods:
public static intbitCount(typeval)
Returns the number of one-bits in the two's complement binary
representations of val.
public statictypehighestOneBit(typeval)
Returns a value consisting of all zero-bits, except for a single one-bit, in the
same position as the highest-order (left-most) one-bit in val.
public statictypelowestOneBit(typeval)
Returns a value consisting of all zero-bits, except for a single one-bit, in the
same position as the lowest-order (right-most) one-bit in val.
public static intnumberOfLeadingZeros(typeval)
Returns the number of zero-bits preceding the highest-order one-bit in val.
public static intnumberOfTrailingZeros(typeval)
Returns the number of zero-bits following the lowest-order one-bit in val.
public statictypereverse(typeval)
Returns the value obtained by reversing the order of the bits in val.
public statictyperotateLeft(typeval, int distance)
Returns the value obtained by rotating the bits in val to the left. In a left
rotation the high-order bit moved out on the left becomes the lowest-order bit
on the right. Rotating to the left by a negative distance is the same as rotating
to the right by a positive distance.
public statictyperotateRight(typeval, int distance)