public final class Integers
extends java.lang.Object
Integer
class.Modifier and Type | Method and Description |
---|---|
static int |
compare(int x,
int y)
Compares two
int values numerically. |
static int |
compareUnsigned(int x,
int y)
Compares two
int values numerically treating the values
as unsigned. |
static int |
divideUnsigned(int dividend,
int divisor)
Returns the unsigned quotient of dividing the first argument by
the second where each argument and the result is interpreted as
an unsigned value.
|
static int |
hashCode(int value)
Returns a hash code for a
int value; compatible with
Integer.hashCode() . |
static int |
max(int a,
int b)
Returns the greater of two
int values
as if by calling Math.max . |
static int |
min(int a,
int b)
Returns the smaller of two
int values
as if by calling Math.min . |
static int |
remainderUnsigned(int dividend,
int divisor)
Returns the unsigned remainder from dividing the first argument
by the second where each argument and the result is interpreted
as an unsigned value.
|
static int |
sum(int a,
int b)
Adds two integers together as per the + operator.
|
static long |
toUnsignedLong(int x)
Converts the argument to a
long by an unsigned
conversion. |
public static int hashCode(int value)
int
value; compatible with
Integer.hashCode()
.value
- the value to hashint
value.public static long toUnsignedLong(int x)
long
by an unsigned
conversion. In an unsigned conversion to a long
, the
high-order 32 bits of the long
are zero and the
low-order 32 bits are equal to the bits of the integer
argument.
Consequently, zero and positive int
values are mapped
to a numerically equal long
value and negative int
values are mapped to a long
value equal to the
input plus 232.x
- the value to convert to an unsigned long
long
by an unsigned
conversionpublic static int divideUnsigned(int dividend, int divisor)
Note that in two's complement arithmetic, the three other
basic arithmetic operations of add, subtract, and multiply are
bit-wise identical if the two operands are regarded as both
being signed or both being unsigned. Therefore separate addUnsigned
, etc. methods are not provided.
dividend
- the value to be divideddivisor
- the value doing the dividingremainderUnsigned(int, int)
public static int remainderUnsigned(int dividend, int divisor)
dividend
- the value to be divideddivisor
- the value doing the dividingdivideUnsigned(int, int)
public static int compare(int x, int y)
int
values numerically.
The value returned is identical to what would be returned by:
Integer.valueOf(x).compareTo(Integer.valueOf(y))
x
- the first int
to comparey
- the second int
to compare0
if x == y
;
a value less than 0
if x < y
; and
a value greater than 0
if x > y
public static int compareUnsigned(int x, int y)
int
values numerically treating the values
as unsigned.x
- the first int
to comparey
- the second int
to compare0
if x == y
; a value less
than 0
if x < y
as unsigned values; and
a value greater than 0
if x > y
as
unsigned valuespublic static int sum(int a, int b)
a
- the first operandb
- the second operanda
and b
BinaryOperator
public static int max(int a, int b)
int
values
as if by calling Math.max
.a
- the first operandb
- the second operanda
and b
BinaryOperator
public static int min(int a, int b)
int
values
as if by calling Math.min
.a
- the first operandb
- the second operanda
and b
BinaryOperator