public final class QuickMath extends Object
QuickMath
contains methods to perform optimized mathematical operations.
Methods are allowed to put additional constraints on the range of input values if required for efficiency.
Methods are not required to perform validation of input arguments, but they have to indicate the constraints
in theirs contract.Modifier and Type | Method and Description |
---|---|
static int |
divideByAndCeilToInt(double d,
int k) |
static long |
divideByAndCeilToLong(double d,
int k) |
static int |
divideByAndRoundToInt(double d,
int k) |
static long |
divideByAndRoundToLong(double d,
int k) |
static boolean |
isPowerOfTwo(long x)
Return true if input argument is power of two.
|
static int |
log2(int value) |
static int |
log2(long value) |
static int |
modPowerOfTwo(int a,
int b)
Computes the remainder of the division of
a by b . |
static long |
modPowerOfTwo(long a,
int b)
Computes the remainder of the division of
a by b . |
static int |
nextPowerOfTwo(int value) |
static long |
nextPowerOfTwo(long value) |
static int |
normalize(int value,
int factor) |
static long |
normalize(long value,
int factor) |
public static boolean isPowerOfTwo(long x)
x
- true
if x
is power of twopublic static int modPowerOfTwo(int a, int b)
a
by b
.
a
has to be non-negative integer and b
has to be power of two
otherwise the result is undefined.a
- b
- public static long modPowerOfTwo(long a, int b)
a
by b
.
a
has to be non-negative integer and b
has to be power of two
otherwise the result is undefined.a
- b
- public static int nextPowerOfTwo(int value)
public static long nextPowerOfTwo(long value)
public static int log2(int value)
public static int log2(long value)
public static int divideByAndCeilToInt(double d, int k)
public static long divideByAndCeilToLong(double d, int k)
public static int divideByAndRoundToInt(double d, int k)
public static long divideByAndRoundToLong(double d, int k)
public static int normalize(int value, int factor)
public static long normalize(long value, int factor)
Copyright © 2014 Hazelcast, Inc.. All Rights Reserved.