public final class Number160 extends Number implements Comparable<Number160>
| Modifier and Type | Field and Description |
|---|---|
static int |
BITS |
static int |
BYTE_ARRAY_SIZE |
static int |
CHARS_PER_INT |
static int |
INT_ARRAY_SIZE |
static Number160 |
MAX_VALUE |
static Number160 |
ONE |
static Number160 |
ZERO |
| Constructor and Description |
|---|
Number160()
Create a Key with value 0.
|
Number160(byte[] val)
Creates a new Key using the byte array.
|
Number160(byte[] val,
int offset,
int length)
Creates a new Key using the byte array.
|
Number160(int... val)
Create an instance with an integer array.
|
Number160(int val)
Creates a Key with the integer value.
|
Number160(long val)
Creates a Key with the long value.
|
Number160(long timestamp,
Number160 number96)
Creates a new key with a long for the first 64bits, and using the lower 96bits for the rest.
|
Number160(Random random)
Creates a new Key with random values in it.
|
Number160(String val)
Create a Key from a string.
|
| Modifier and Type | Method and Description |
|---|---|
int |
bitLength()
Calculates the number of bits used to represent this number.
|
int |
compareTo(Number160 o) |
static Number160 |
createHash(int integerValue)
Create a new Number160 from the integer, which fills all the 160bits.
|
static Number160 |
createHash(long longValue)
Creates a new Number160 from the long, which fills all the 160 bits.
|
static Number160 |
createHash(String string)
Creates a new Number160 using SHA1 on the string.
|
double |
doubleValue() |
boolean |
equals(Object obj) |
float |
floatValue() |
int |
hashCode() |
int |
intValue() |
boolean |
isZero()
Checks if this number is zero.
|
long |
longValue() |
Number160 |
number96() |
long |
timestamp() |
byte[] |
toByteArray()
Returns a byte array, which is always of size 20.
|
int |
toByteArray(byte[] me,
int offset)
Fills the byte array with this number.
|
int[] |
toIntArray()
Returns a copy of the backing array, which is always of size 5.
|
String |
toString() |
String |
toString(boolean removeLeadingZero)
Shows the content in a human readable manner.
|
Number160 |
xor(Number160 key)
Xor operation.
|
byteValue, shortValuepublic static final int BITS
public static final int INT_ARRAY_SIZE
public static final int BYTE_ARRAY_SIZE
public static final int CHARS_PER_INT
public static final Number160 ZERO
public static final Number160 ONE
public static final Number160 MAX_VALUE
public Number160()
public Number160(int... val)
val - The value to copy to the backing array. Since this class stores 160bit numbers, the array needs to be
of size 5 or smaller.public Number160(String val)
val - The characters allowed are [0-9a-f], which is in hexadecimalpublic Number160(int val)
val - integer valuepublic Number160(long val)
val - long valuepublic Number160(byte[] val)
val - byte arraypublic Number160(byte[] val,
int offset,
int length)
val - byte arrayoffset - The offset where to startlength - the length to readpublic Number160(Random random)
random - The object to create pseudo random numbers. For testing and debugging, the seed in the random class
can be set to make the random values repeatable.public Number160(long timestamp,
Number160 number96)
timestamp - The long value that will be set in the beginning (most significant)number96 - The rest will be filled with this numberpublic long timestamp()
public Number160 number96()
public Number160 xor(Number160 key)
key - The second operand for the xor operationpublic int[] toIntArray()
public int toByteArray(byte[] me,
int offset)
me - the byte arrayoffset - where to start in the byte arraypublic byte[] toByteArray()
public String toString(boolean removeLeadingZero)
removeLeadingZero - Indicates if leading zeros should be removedpublic boolean isZero()
public int bitLength()
public double doubleValue()
doubleValue in class Numberpublic float floatValue()
floatValue in class Numberpublic int compareTo(Number160 o)
compareTo in interface Comparable<Number160>public static Number160 createHash(int integerValue)
integerValue - The value to hash frompublic static Number160 createHash(long longValue)
longValue - The value to hash from (seed)Copyright © 2014. All rights reserved.