|
Algorithm Development Kit 1.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectalgs.model.FloatingPoint
public class FloatingPoint
Provides a standard API for evaluating double numbers when dealing with floating point rounding error.
Specifically, this class enables one to compare two double numbers to see if they are within an epsilon of each other.
Field Summary | |
---|---|
static double |
epsilon
Numbers within this amount are considered to be the same. |
Method Summary | |
---|---|
static int |
compare(double d1,
double d2)
Return -1 if d1 < d2, 0 if d1 == d2, or +1 if d1 > d2. |
static boolean |
greater(double x,
double y)
Given closeness-to-epsilon, is x > y? |
static boolean |
greaterEquals(double x,
double y)
Given closeness-to-epsilon, is x >= y? |
static boolean |
lesser(double x,
double y)
Given closeness-to-epsilon, is x < y? |
static boolean |
lesserEquals(double x,
double y)
Given closeness-to-epsilon, is x <= y? |
static boolean |
same(double d1,
double d2)
When value won't work, because numbers are potentially infinite, then use this one. |
static double |
value(double x)
See if the value is close enough to actually be considered 0.0 and return 0.0 if need be. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double epsilon
Method Detail |
---|
public static int compare(double d1, double d2)
d1
- first number against which to compared2
- second number being comparedpublic static boolean same(double d1, double d2)
Standarard means for comparing double when dealing with the special quantities, NaN and infinite numbers. Also properly ensures that numbers "close to zero" (within an epsilon) are to be treated as zero for this computation.
d1
- first number being comparedd2
- second number being comparedpublic static double value(double x)
Otherwise the value is returned.
x
- value being consideredpublic static boolean greaterEquals(double x, double y)
public static boolean greater(double x, double y)
public static boolean lesserEquals(double x, double y)
public static boolean lesser(double x, double y)
|
Algorithm Development Kit 1.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |