public final class Longs
extends java.lang.Object
long
values.Modifier and Type | Method and Description |
---|---|
static int |
compareUnsigned(long x,
long y)
Compares two
long values numerically treating the values
as unsigned. |
static byte[] |
copyTo(long value,
byte[] bytes,
int offset)
Copy the byte value of
value into bytes
starting at offset . |
static long |
fromByteArray(byte[] bytes)
Exactly equivalent to
fromByteArray(bytes, 0) . |
static long |
fromByteArray(byte[] bytes,
int offset)
Decode a long from array
bytes at offset . |
static long |
fromBytes(byte b0,
byte b1,
byte b2,
byte b3,
byte b4,
byte b5,
byte b6,
byte b7)
Assemble a
long value from it's component bytes. |
static byte[] |
toByteArray(long value)
Create a byte array of length
Long.BYTES , and
populate it with value in big-endian order. |
public static byte[] toByteArray(long value)
Long.BYTES
, and
populate it with value
in big-endian order.value
- The value to convertpublic static byte[] copyTo(long value, byte[] bytes, int offset)
value
into bytes
starting at offset
. A total of Long.BYTES
will be written to bytes
.value
- The value to convertbytes
- The array to write the value intooffset
- The offset at which to write the valuebytes
public static long fromByteArray(byte[] bytes)
fromByteArray(bytes, 0)
.bytes
- The byte array to decode to a longfromByteArray(byte[], int)
public static long fromByteArray(byte[] bytes, int offset)
bytes
at offset
.
Bytes from array bytes[offset]
up to and including
bytes[offset + Long.BYTES - 1]
will be read from
array bytes
.bytes
- The byte array to decode to a longoffset
- The offset within the array to start decodingpublic static long fromBytes(byte b0, byte b1, byte b2, byte b3, byte b4, byte b5, byte b6, byte b7)
long
value from it's component bytes.b0
- Most significant byteb1
- Next most significant byteb2
- …b3
- …b4
- …b5
- …b6
- Next least significant byteb7
- Least significant bytelong
value represented by the arguments.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 values