|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.javasoft.util.numeric.Zero
public class Zero
Zero is a helper class treating values close to zero as zero.
A tolerance or precision can be defined when constructing an instance of
Zero.
| Field Summary | |
|---|---|
static int |
DEFAULT_PRECISION
default precision 10, meaning 10 decimal places |
static double |
DEFAULT_TOLERANCE
default precision 10-10, meaning 10 decimal places |
static double |
EPS_TOLERANCE
normal machine precision for doubles, that is 2-52 |
int |
mPrecision
|
double |
mZeroNeg
|
double |
mZeroPos
|
| Constructor Summary | |
|---|---|
Zero()
Constructor using DEFAULT_PRECISION |
|
Zero(double tolerance)
Constructor using the specified tolerance |
|
Zero(int precision)
Constructor using the specified precision |
|
| Method Summary | |
|---|---|
boolean |
isNegative(double value)
|
boolean |
isNegPos(double valueA,
double valueB)
|
boolean |
isNonZero(double value)
|
boolean |
isPositive(double value)
|
boolean |
isZero(double value)
|
boolean |
isZeroNeg(double value)
|
boolean |
isZeroPos(double value)
|
double |
roundZero(double value)
If the given value is within the zero tolerance, zero is returned, and the given value otherwise. |
int |
sgn(double value)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_PRECISION
public static final double DEFAULT_TOLERANCE
public static final double EPS_TOLERANCE
public final int mPrecision
public final double mZeroPos
public final double mZeroNeg
| Constructor Detail |
|---|
public Zero()
DEFAULT_PRECISION
public Zero(double tolerance)
tolerance - a number close to zero, absolute values larger than
the absolute value of tolerance are
treated non-zero, other values as zeropublic Zero(int precision)
precision - the precision in decimal places, absolute values
larger than 10-abs(precision)
are treated non-zero, other values as zero| Method Detail |
|---|
public int sgn(double value)
public boolean isZero(double value)
public boolean isNonZero(double value)
public boolean isZeroNeg(double value)
public boolean isZeroPos(double value)
public boolean isNegative(double value)
public boolean isPositive(double value)
public boolean isNegPos(double valueA,
double valueB)
public double roundZero(double value)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||