public class MathUtil
extends java.lang.Object
Constructor and Description |
---|
MathUtil() |
Modifier and Type | Method and Description |
---|---|
static double |
log2(double value)
Returns the base 2 logarithm of a number.
|
static int |
log2i(double value)
Returns the smallest integer x such that 2^x is greater than or equal to the specified value.
|
static double |
pow2(double value)
Returns the smallest power of 2 greater than or equal to the specified value.
|
static int |
pow2i(double value)
Returns the smallest power of 2 greater than or equal to the specified value.
|
static long |
pow2L(double value)
Returns the smallest power of 2 greater than or equal to the specified value.
|
public static double log2(double value)
log(value)/log(2)
public static int log2i(double value)
Pow2(37)
returns 6 (because 2^6 is the smallest power of two greater than or equal to 37)value
- public static double pow2(double value)
Pow2(37)
returns 64 because 32 < 37 <= 64public static int pow2i(double value)
Pow2(37)
returns 64, which is the smallest power of 2 greater than or equal to 37.
Note: If the return value might exceed the range of an integer,
then pow2L(double)
or pow2(double)
should be used instead.public static long pow2L(double value)
Pow2(37)
returns 64, which is the smallest power of 2 greater than or equal to 37.