|
ePOST API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rice.p2p.util.MathUtils
public class MathUtils
This class contains a large number of static methods for performing math operations.
Field Summary | |
---|---|
static char[] |
HEX_ARRAY
The array used for conversion to hexidecimal |
Method Summary | |
---|---|
static int |
byteArrayToInt(byte[] input)
Utility method for converting a byte[] into a int |
static long |
byteArrayToLong(byte[] input)
Utility method for converting a byte[] into a long |
static byte[] |
fromHex(java.lang.String text)
Utility method which converts a hex string to a byte[] |
protected static byte |
getByte(char c)
Utility method for converting a char to a byte |
static byte[] |
intToByteArray(int input)
Utility method for converting a int into a byte[] |
static void |
intToByteArray(int input,
byte[] output,
int offset)
Utility method for converting a int into a byte[] |
static byte[] |
longToByteArray(long input)
Utility method for converting a long into a byte[] |
static void |
longToByteArray(long input,
byte[] output,
int offset)
Utility method for converting a long into a byte[] |
static int |
mod(int a,
int b)
Utility which does *proper* modding, where the result is guaranteed to be positive. |
static byte[] |
randomBytes(int len,
RandomSource random)
Method which returns a specified number of random bytes |
static int |
randomInt(RandomSource random)
Method which returns a random int |
static java.lang.String |
toHex(byte[] text)
Utility method which converts a byte[] to a hexidecimal string of characters, in lower case |
static byte[] |
xor(byte[] a,
byte[] b)
Utility method which xors two given byte arrays, of equal length, and returns the results |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char[] HEX_ARRAY
Method Detail |
---|
public static int mod(int a, int b)
a
- The modeeb
- The value to mod by
public static byte[] xor(byte[] a, byte[] b)
a
- The first arrayb
- The second array
public static byte[] randomBytes(int len, RandomSource random)
len
- The number of random bytes to generatepublic static int randomInt(RandomSource random)
len
- The number of random bytes to generatepublic static java.lang.String toHex(byte[] text)
text
- The array to convert
public static byte[] fromHex(java.lang.String text)
text
- The text to convert
protected static byte getByte(char c)
c
- The char
public static byte[] intToByteArray(int input)
input
- The log to convert
public static void intToByteArray(int input, byte[] output, int offset)
input
- The log to convertpublic static int byteArrayToInt(byte[] input)
input
- The byte[] to convert
public static byte[] longToByteArray(long input)
input
- The log to convert
public static void longToByteArray(long input, byte[] output, int offset)
input
- The log to convertpublic static long byteArrayToLong(byte[] input)
input
- The byte[] to convert
|
ePOST API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |