public class NumberUtil extends Object
Modifier and Type | Field and Description |
---|---|
static double |
LOGE_2 |
Constructor and Description |
---|
NumberUtil() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
fromHex(String string,
int offset,
int count)
Converts the specified array of hex characters into an array of
byte s
(low byte first). |
static double |
log2(double value)
Computes the
log2 (log-base-two) of the specified value. |
static String |
toHex(byte[] bytes,
int offset,
int count)
Converts the specified array of
byte s into a string of
hex characters (low byte first). |
public static final double LOGE_2
public static double log2(double value)
log2
(log-base-two) of the specified value.value
- the double
for which the log2
is
desired.log2
of the specified valuepublic static String toHex(byte[] bytes, int offset, int count)
byte
s into a string of
hex characters (low byte
first).bytes
- the array of byte
s that are to be converted.
This cannot be null
though it may be empty.offset
- the offset in bytes
at which the bytes will
be taken. This cannot be negative and must be less than
bytes.length - 1
.count
- the number of bytes to be retrieved from the specified array.
This cannot be negative. If greater than bytes.length - offset
then that value is used.count
characters that represents
the specified byte array in hex. This will never be null
though it may be empty if bytes
is empty or count
is zero.IllegalArgumentException
- if offset
is greater than
or equal to bytes.length
.fromHex(String, int, int)
public static byte[] fromHex(String string, int offset, int count)
byte
s
(low byte
first).string
- the string of hex characters to be converted into byte
s.
This cannot be null
though it may be blank.offset
- the offset in the string at which the characters will be
taken. This cannot be negative and must be less than string.length() - 1
.count
- the number of characters to be retrieved from the specified
string. This cannot be negative and must be divisible by two
(since there are two characters per byte
).byte
s that were converted from the
specified string (in the specified range). This will never be
null
though it may be empty if string
is empty or count
is zero.IllegalArgumentException
- if offset
is greater than
or equal to string.length()
or if count
is not divisible by two.toHex(byte[], int, int)
Copyright © 2015. All rights reserved.