|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.util.MathUtils
public class MathUtils
This is a utility class with mathematical helper functions.
Method Summary | |
---|---|
static void |
checkPowerOf2(int len)
Check if a value is a power of two. |
static int |
compareInt(int a,
int b)
Compare two values. |
static int |
compareLong(long a,
long b)
Compare two values. |
static int |
convertLongToInt(long l)
Convert a long value to an int value. |
static int |
nextPowerOf2(int x)
Get the value that is equal or higher than this value, and that is a power of two. |
static int |
precision(java.math.BigDecimal x)
Compatibility for BigDecimal.precision() which is not available in Java 1.4. |
static void |
randomBytes(byte[] bytes)
Get a number of pseudo random bytes. |
static int |
randomInt(int lowerThan)
Get a pseudo random int value between 0 (including and the given value (excluding). |
static int |
reverseInt(int x)
Reverse the bits in a 32 bit integer. |
static long |
reverseLong(long x)
Reverse the bits in a 64 bit long. |
static int |
roundUpInt(int x,
int blockSizePowerOf2)
Round the value up to the next block size. |
static long |
roundUpLong(long x,
long blockSizePowerOf2)
Round the value up to the next block size. |
static byte[] |
secureRandomBytes(int len)
Get a number of cryptographically secure pseudo random bytes. |
static int |
secureRandomInt(int lowerThan)
Get a cryptographically secure pseudo random int value between 0 (including and the given value (excluding). |
static long |
secureRandomLong()
Get a cryptographically secure pseudo random long value. |
static java.math.BigDecimal |
setScale(java.math.BigDecimal bd,
int scale)
Set the scale of a BigDecimal value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static int roundUpInt(int x, int blockSizePowerOf2)
x
- the value to be roundedblockSizePowerOf2
- the block size
public static long roundUpLong(long x, long blockSizePowerOf2)
x
- the value to be roundedblockSizePowerOf2
- the block size
public static void checkPowerOf2(int len)
len
- the value to check
java.lang.RuntimeException
- if it is not a power of twopublic static int nextPowerOf2(int x)
x
- the original value
public static java.math.BigDecimal setScale(java.math.BigDecimal bd, int scale)
bd
- the BigDecimal valuescale
- the new scale
public static int convertLongToInt(long l)
l
- the value to convert
public static int reverseInt(int x)
x
- the original value
public static long reverseLong(long x)
x
- the original value
public static int precision(java.math.BigDecimal x)
x
- the value
public static int compareInt(int a, int b)
a
- the first valueb
- the second value
public static int compareLong(long a, long b)
a
- the first valueb
- the second value
public static long secureRandomLong()
public static void randomBytes(byte[] bytes)
bytes
- the target arraypublic static byte[] secureRandomBytes(int len)
len
- the number of bytes
public static int randomInt(int lowerThan)
lowerThan
- the value returned will be lower than this value
public static int secureRandomInt(int lowerThan)
lowerThan
- the value returned will be lower than this value
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |