Package hec.heclib.util
Class HecDouble
java.lang.Object
hec.heclib.util.HecDouble
- All Implemented Interfaces:
Serializable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected boolean
protected double
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(double value) void
int
compare
(double val) int
compareTo
(double val) Compares this value with double input value (precision ignored).int
compareTo
(double val, double tolerance) int
Compares this value with input value (precision accounted for).int
void
divide
(double value) void
boolean
equal
(double value, double tolerance) boolean
boolean
equalsWithinPercent
(HecDouble value, double percent) boolean
equalsWithinTolerance
(HecDouble value, double tolerance) static int
estimatePrecision
(double value, int sigDigits) static String
formatPattern
(int precision) static String
formatPattern
(int precision, char decimalSeparator) boolean
double
getTolerances
(HecDouble value) boolean
greaterThan
(double value, double tolerance) boolean
greaterThan
(HecDouble value) boolean
greaterThanEqual
(double value, double tolerance) boolean
greaterThanEqual
(HecDouble value) boolean
boolean
lessThan
(double value, double tolerance) boolean
boolean
lessThanEqual
(double value, double tolerance) boolean
lessThanEqual
(HecDouble value) void
multiply
(double value) void
int
boolean
void
set
(double value) void
set
(double value, int precision) void
int
int
setPrecision
(int precision) void
setShowCommas
(boolean showCommas) void
setSignificantDigits
(int sigDigits) void
string()
string
(boolean printCommas) string
(boolean printCommas, DecimalFormatSymbols symbols) static String
string
(double value, int precision, boolean printCommas) static String
string
(double value, int precision, boolean printCommas, DecimalFormatSymbols symbols) static String
string
(double value, int precision, boolean printCommas, DecimalFormatSymbols symbols, String undefinedString) string
(int precision, boolean printCommas) void
subtract
(double value) void
toString()
double
value()
-
Field Details
-
NO_PRECISION_SET
public static final int NO_PRECISION_SET- See Also:
-
EXPONENTIAL_NUMBER
public static final int EXPONENTIAL_NUMBER- See Also:
-
NO_VALUE_SET
public static final int NO_VALUE_SET- See Also:
-
_precision
protected int _precision -
_value
protected double _value -
_showCommas
protected boolean _showCommas
-
-
Constructor Details
-
HecDouble
public HecDouble() -
HecDouble
-
HecDouble
public HecDouble(double value, int precision) -
HecDouble
public HecDouble(double value) -
HecDouble
-
-
Method Details
-
set
-
set
public void set(double value) -
set
public void set(double value, int precision) -
set
-
setUndefined
public void setUndefined() -
setPrecision
public int setPrecision(int precision) -
setSignificantDigits
public void setSignificantDigits(int sigDigits) -
setShowCommas
public void setShowCommas(boolean showCommas) -
getShowCommas
public boolean getShowCommas() -
estimatePrecision
public static int estimatePrecision(double value, int sigDigits) -
isDefined
public boolean isDefined() -
toString
-
string
-
string
-
string
-
string
-
string
-
string
-
string
public static String string(double value, int precision, boolean printCommas, DecimalFormatSymbols symbols) -
string
public static String string(double value, int precision, boolean printCommas, DecimalFormatSymbols symbols, String undefinedString) -
formatPattern
-
formatPattern
-
value
public double value() -
precisionSet
public boolean precisionSet() -
precision
public int precision() -
add
public void add(double value) -
add
-
subtract
public void subtract(double value) -
subtract
-
multiply
public void multiply(double value) -
multiply
-
divide
public void divide(double value) -
divide
-
equals
-
lessThan
-
lessThanEqual
-
greaterThan
-
greaterThanEqual
-
equalsWithinTolerance
-
equalsWithinPercent
-
equal
public boolean equal(double value, double tolerance) -
lessThan
public boolean lessThan(double value, double tolerance) -
lessThanEqual
public boolean lessThanEqual(double value, double tolerance) -
greaterThan
public boolean greaterThan(double value, double tolerance) -
greaterThanEqual
public boolean greaterThanEqual(double value, double tolerance) -
getTolerances
-
compareTo
Compares this value with input value (precision accounted for).- Returns:
- 0 if values are equal; -1 if this value is undefined or less than input value; 1 if this value is greater than input value or input value is undefined
-
compareTo
-
compareTo
public int compareTo(double val, double tolerance) -
compare
public int compare(double val) -
compareTo
public int compareTo(double val) Compares this value with double input value (precision ignored).- Returns:
- 0 if values are equal; -1 if this value is undefined or less than input value; 1 if this value is greater than input value or input value is undefined
-