public final class NumberUtils extends Object
NumberUtils
class is a collection of utility class fields and
methods for number handling.Modifier and Type | Field and Description |
---|---|
static int |
HASH_PRIME
A prime number used to calculate hash code.
|
static int |
MASK_BYTE
A mask value which represents all bits in a byte value.
|
static long |
MASK_INTEGER
A mask value which represents all bits in an integer value.
|
static int |
MASK_SHORT
A mask value which represents all bits in a short value.
|
static int |
NUM_OCTETS_BYTE
The number of octets in a byte value.
|
static int |
NUM_OCTETS_INTEGER
The number of octets in an integer value.
|
static int |
NUM_OCTETS_SHORT
The number of octets in a short integer value.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
equalsDouble(double d1,
double d2)
Determine whether the given double numbers are identical.
|
static int |
getUnsigned(byte b)
Return the unsigned value of the given byte value.
|
static long |
getUnsigned(int i)
Return the unsigned value of the given integer value.
|
static BigInteger |
getUnsigned(long l)
Return the unsigned value of the given long integer value.
|
static int |
getUnsigned(short s)
Return the unsigned value of the given short value.
|
static int |
hashCode(double value)
Return a hash code of the given double value.
|
static int |
hashCode(long value)
Return a hash code of the given long integer value.
|
static void |
setInt(byte[] array,
int off,
int value)
Set an integer value into the given byte array in network byte order.
|
static void |
setShort(byte[] array,
int off,
short value)
Set a short integer value into the given byte array in network byte
order.
|
static Byte |
toByte(Number num)
Convert the given number into a
Byte instance. |
static byte[] |
toBytes(int v)
Convert an integer value into an byte array.
|
static byte[] |
toBytes(short v)
Convert a short integer value into an byte array.
|
static int |
toInteger(byte[] b)
Convert a 4 bytes array into an integer number.
|
static Integer |
toInteger(Number num)
Convert the given number into a
Integer instance. |
static Long |
toLong(Number num)
Convert the given number into a
Long instance. |
static short |
toShort(byte[] b)
Convert a 2 bytes array into a short integer number.
|
static Short |
toShort(Number num)
Convert the given number into a
Short instance. |
public static final int HASH_PRIME
public static final int NUM_OCTETS_INTEGER
public static final int NUM_OCTETS_SHORT
public static final int NUM_OCTETS_BYTE
public static final int MASK_BYTE
public static final int MASK_SHORT
public static final long MASK_INTEGER
public static int hashCode(long value)
value
- A long integer value.public static int hashCode(double value)
value
- A double value.public static void setInt(byte[] array, int off, int value)
array
- A byte array.off
- Index of array
to store value.value
- An integer value.public static void setShort(byte[] array, int off, short value)
array
- A byte array.off
- Index of array
to store value.value
- A short integer value.public static int toInteger(byte[] b)
b
- A 4 bytes array.NullPointerException
- b
is null
.IllegalArgumentException
- The length of b
is not 4.public static short toShort(byte[] b)
b
- A 2 bytes array.NullPointerException
- b
is null
.IllegalArgumentException
- The length of b
is not 2.public static byte[] toBytes(int v)
v
- An integer value.public static byte[] toBytes(short v)
v
- A short integer value.public static int getUnsigned(byte b)
b
- A byte value.public static int getUnsigned(short s)
s
- A short value.public static long getUnsigned(int i)
i
- An integer value.public static BigInteger getUnsigned(long l)
l
- A long integer value.BigInteger
instance which represents the unsigned
long integer value.public static Integer toInteger(Number num)
Integer
instance.public static boolean equalsDouble(double d1, double d2)
d1
- The first double number to be compared.d2
- The second double number to be compared.true
only if the given two double numbers are
identical.Double.equals(Object)
Copyright © 2018 OpenDaylight. All rights reserved.