public class DoubleUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static double |
EPSILON |
Constructor and Description |
---|
DoubleUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isDivisibleBy(double value,
double divisor)
Checks whether the specified value is divisible by divisor
|
static boolean |
isPowerOf(double value,
double power,
double logBase)
Checks whether the value is a power of some specified power value with specified log base
|
static boolean |
isRealNumber(double number)
Checks whether the specified value is a real number
|
static boolean |
isZero(double number)
Checks whether the specified value is zero
|
static double |
log(double value,
double base)
Computes log value with specified log base
|
static double |
round(double value,
int decimals)
Rounds value to nearest value considering specified amount of decimal places
|
static double |
roundDown(double value,
double nearest)
Rounds down specified value to value which is divisible by nearest value
|
static double |
roundDownPower(double value,
double power,
double logBase) |
static double |
roundOff(double value)
Rounds value to nearest integer value
|
static double |
roundOff(double value,
int decimals,
boolean toNearest)
Rounds value to nearest value considering specified amount of decimal places
|
static double |
roundUp(double value,
double nearest)
Rounds up specified value to value which is divisible by nearest value
|
static double |
roundUpPower(double value,
double power,
double logBase) |
public static final double EPSILON
public static double roundUp(double value, double nearest)
value
- The value to round upnearest
- The nearest point divisorpublic static double roundDown(double value, double nearest)
value
- The value to round downnearest
- The nearest point divisorpublic static boolean isDivisibleBy(double value, double divisor)
value
- The value to checkdivisor
- The divisor valuepublic static boolean isRealNumber(double number)
number
- The value to checkpublic static boolean isZero(double number)
number
- The value to checkpublic static double log(double value, double base)
value
- The valuebase
- The log basepublic static boolean isPowerOf(double value, double power, double logBase)
value
- The value to checkpower
- The power valuelogBase
- The log basepublic static double roundUpPower(double value, double power, double logBase)
public static double roundDownPower(double value, double power, double logBase)
public static double roundOff(double value, int decimals, boolean toNearest)
value
- The value to rounddecimals
- The amount of decimal places to roundtoNearest
- value indicating whether we need to round to nearest integer valuepublic static double round(double value, int decimals)
value
- The value to rounddecimals
- The amount of decimal places to roundpublic static double roundOff(double value)
value
- The value to round