public final class NumberFactory extends java.lang.Object
int
values
or one long
value, or a sequence of bytes.Modifier and Type | Method | Description |
---|---|---|
static int |
extractHi(long v) |
Creates an
int from a long , using the high order bits. |
static int |
extractLo(long v) |
Creates an
int from a long , using the low order bits. |
static boolean |
makeBoolean(int v) |
|
static boolean |
makeBoolean(long v) |
|
static byte[] |
makeByteArray(int v) |
Splits an
int into 4 bytes. |
static byte[] |
makeByteArray(int[] input) |
Splits an array of
int values into a sequence of bytes. |
static byte[] |
makeByteArray(long v) |
Splits a
long into 8 bytes. |
static byte[] |
makeByteArray(long[] input) |
Splits an array of
long values into a sequence of bytes. |
static double |
makeDouble(int v,
int w) |
|
static double |
makeDouble(long v) |
|
static float |
makeFloat(int v) |
|
static int |
makeInt(byte[] input) |
Creates an
int from 4 bytes. |
static int |
makeInt(long v) |
Creates an
int from a long . |
static int[] |
makeIntArray(byte[] input) |
Creates an array of
int values from a sequence of bytes. |
static long |
makeLong(byte[] input) |
Creates a
long from 8 bytes. |
static long |
makeLong(int v,
int w) |
|
static long[] |
makeLongArray(byte[] input) |
Creates an array of
long values from a sequence of bytes. |
public static boolean makeBoolean(int v)
v
- Number.public static boolean makeBoolean(long v)
v
- Number.public static double makeDouble(long v)
v
- Number.double
value in the interval [0, 1]
.public static double makeDouble(int v, int w)
v
- Number (high order bits).w
- Number (low order bits).double
value in the interval [0, 1]
.public static float makeFloat(int v)
v
- Number.float
value in the interval [0, 1]
.public static long makeLong(int v, int w)
v
- Number (high order bits).w
- Number (low order bits).long
value.public static int makeInt(long v)
int
from a long
.v
- Number.int
value made from the "xor" of the
high order bits
and
low order bits
of v
.public static int extractHi(long v)
int
from a long
, using the high order bits.
The returned value is such that if
vL = extractLo(v);
vH = extractHi(v);
then v
is equal to makeLong(vH, vL)
.
v
- Number.int
value made from the most significant bits
of v
.public static int extractLo(long v)
int
from a long
, using the low order bits.
The returned value is such that if
vL = extractLo(v);
vH = extractHi(v);
then v
is equal to makeLong(vH, vL)
.
v
- Number.int
value made from the least significant bits
of v
.public static byte[] makeByteArray(long v)
long
into 8 bytes.v
- Value.public static long makeLong(byte[] input)
long
from 8 bytes.input
- Input.java.lang.IllegalArgumentException
- if input.length != 8
.public static byte[] makeByteArray(long[] input)
long
values into a sequence of bytes.
This method calls makeByteArray(long)
for each element of
the input
.input
- Input.public static long[] makeLongArray(byte[] input)
long
values from a sequence of bytes.
This method calls makeLong(byte[])
for each subsequence
of 8 bytes.input
- Input.long
.java.lang.IllegalArgumentException
- if input.length
is not
a multiple of 8.public static byte[] makeByteArray(int v)
int
into 4 bytes.v
- Value.public static int makeInt(byte[] input)
int
from 4 bytes.input
- Input.java.lang.IllegalArgumentException
- if input.length != 4
.public static byte[] makeByteArray(int[] input)
int
values into a sequence of bytes.
This method calls makeByteArray(int)
for each element of
the input
.input
- Input.public static int[] makeIntArray(byte[] input)
int
values from a sequence of bytes.
This method calls makeInt(byte[])
for each subsequence
of 4 bytes.input
- Input. Length must be a multiple of 4.int
.java.lang.IllegalArgumentException
- if input.length
is not
a multiple of 4.Copyright © 2016–2018 The Apache Software Foundation. All rights reserved.