|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjopt.csp.util.DoubleUtil
Double type utility functions
Field Summary | |
static double |
DEFAULT_PRECISION
|
Constructor Summary | |
DoubleUtil()
|
Method Summary | |
static int |
compare(double val1,
double val2,
double precision)
Compares two values using a given precision to determine if they are equal |
static double |
getMax(CspNumExpr expr)
Returns maximum value of a numeric expression as a double type |
static double |
getMax(VariableSolution sol)
Returns maximum value of a numeric expression as a double type |
static double |
getMin(CspNumExpr expr)
Returns minimum value of a numeric expression as a double type |
static double |
getMin(VariableSolution sol)
Returns minimum value of a numeric expression as a double type |
static int |
intCeil(double n)
Returns integer value for a number rounding using ceiling method if necessary |
static int |
intFloor(double n)
Returns integer value for a number rounding using floor method if necessary |
static boolean |
isEqual(double val1,
double val2,
double precision)
Returns true if two values are within precision of one another. |
static boolean |
isIntEquivalent(double val)
Returns true if value is equivalent to an integer value |
static boolean |
isLongEquivalent(double val)
Returns true if value is equivalent to a long value |
static long |
longCeil(double n)
Returns long value for a number rounding using ceiling method if necessary |
static long |
longFloor(double n)
Returns long value for a number rounding using floor method if necessary |
static double |
next(double v)
Returns the next higher (towards positive infinity) double precision floating-point value. |
static double |
previous(double v)
Returns the next lower (towards negative infinity) double precision floating-point value. |
static double |
returnMinMaxIfClose(double minCurrent,
double maxCurrent,
double newVal,
double precision)
Returns a min or max value if it is close enough to a value for comparison based on a precision value |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final double DEFAULT_PRECISION
Constructor Detail |
public DoubleUtil()
Method Detail |
public static double next(double v)
public static double previous(double v)
public static double returnMinMaxIfClose(double minCurrent, double maxCurrent, double newVal, double precision)
minCurrent
- Minimum possible current value that will be returned if new value is close enough given scalemaxCurrent
- Maximum possible current value that will be returned if new value is close enough given scalenewVal
- Value that is to be checked to ensure it is close enough to another valueprecision
- Precision values must fall within to be equalpublic static int compare(double val1, double val2, double precision)
val1
- First value to compareval2
- Second value to compareprecision
- Precision values must fall within to be equalpublic static boolean isEqual(double val1, double val2, double precision)
val1
- First value to compareval2
- Second value to compareprecision
- Precision values must fall within to return true.
When comparing values where at least one of them is of magnitude
less than one, this is an absolute precision: a simple difference.
When comparing values both greater than one, this is a fractional
error not an absolute plus or minus bounds. Therefore 1,000,000
and 1,000,001 are equal if precision is set to .000002.public static int intCeil(double n)
public static int intFloor(double n)
public static boolean isIntEquivalent(double val)
public static long longCeil(double n)
public static long longFloor(double n)
public static boolean isLongEquivalent(double val)
public static double getMin(CspNumExpr expr)
public static double getMax(CspNumExpr expr)
public static double getMin(VariableSolution sol)
public static double getMax(VariableSolution sol)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |