public final class Longs
extends java.lang.Object
Long
class.Modifier and Type | Method and Description |
---|---|
static int |
compare(long x,
long y)
Compares two
long values numerically. |
static int |
compareUnsigned(long x,
long y)
Compares two
long values numerically treating the values
as unsigned. |
static long |
divideUnsigned(long dividend,
long 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(long value)
Returns a hash code for a
long value; compatible with
Long.hashCode() . |
static long |
max(long a,
long b)
Returns the greater of two
long values
as if by calling Math.max . |
static long |
min(long a,
long b)
Returns the smaller of two
long values
as if by calling Math.min . |
static long |
remainderUnsigned(long dividend,
long 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 long |
sum(long a,
long b)
Adds two
long values together as per the + operator. |
public static int hashCode(long value)
long
value; compatible with
Long.hashCode()
.value
- the value to hashlong
value.public static long divideUnsigned(long dividend, long 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(long, long)
public static int compare(long x, long y)
long
values numerically.
The value returned is identical to what would be returned by:
Long.valueOf(x).compareTo(Long.valueOf(y))
x
- the first long
to comparey
- the second long
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(long x, long y)
long
values numerically treating the values
as unsigned.x
- the first long
to comparey
- the second long
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 long remainderUnsigned(long dividend, long divisor)
dividend
- the value to be divideddivisor
- the value doing the dividingdivideUnsigned(long, long)
public static long sum(long a, long b)
long
values together as per the + operator.a
- the first operandb
- the second operanda
and b
BinaryOperator
public static long max(long a, long b)
long
values
as if by calling Math.max
.a
- the first operandb
- the second operanda
and b
BinaryOperator
public static long min(long a, long b)
long
values
as if by calling Math.min
.a
- the first operandb
- the second operanda
and b
BinaryOperator