|
||||||||||
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 |
convertLongToInt(long l)
Convert a long value to an int value. |
static byte |
decodeByte(java.lang.String s)
Parse a string to a byte. |
static int |
decodeInt(java.lang.String s)
Parse a string to an int. |
static long |
decodeLong(java.lang.String s)
Parse a string to a long. |
static short |
decodeShort(java.lang.String s)
Parse a string to a short. |
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 |
roundUp(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 long |
scaleUp50Percent(long start,
long min,
long blockSize,
long maxIncrease)
Increase the value by about 50%. |
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 roundUp(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 long scaleUp50Percent(long start, long min, long blockSize, long maxIncrease)
start
- the smallest possible returned valuemin
- the current valueblockSize
- the block sizemaxIncrease
- the maximum increment
public static java.math.BigDecimal setScale(java.math.BigDecimal bd, int scale) throws java.sql.SQLException
bd
- the BigDecimal valuescale
- the new scale
java.sql.SQLException
public static byte decodeByte(java.lang.String s)
s
- the string to parse
public static short decodeShort(java.lang.String s)
s
- the string to parse
public static int decodeInt(java.lang.String s)
s
- the string to parse
public static long decodeLong(java.lang.String s)
s
- the string to parse
public static int convertLongToInt(long l)
l
- the value to convert
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |