public final class NumberUtility extends Object
| Modifier and Type | Field and Description |
|---|---|
static Double |
DOUBLE_ZERO |
| Constructor and Description |
|---|
NumberUtility() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
equals(double lhs,
double rhs,
double delta)
Compares two doubles for equality, within an allowable range
of difference.
|
static boolean |
equals(Number lhs,
Number rhs)
This method is used to compare two numbers.
|
static BigInteger |
getBigInteger(Number value)
Utility method used to convert a Number into a BigInteger.
|
static Double |
getDouble(double value)
Utility method used to convert a double into a Double.
|
static double |
getDouble(Number value)
Utility method used to convert a Number into a double.
|
static int |
getInt(Number value)
This method retrieves an int value from a Number instance.
|
static int |
getInt(String value)
This method retrieves an int value from a String instance.
|
static Integer |
getInteger(Number value)
Utility method used to convert an arbitrary Number into an Integer.
|
static Integer |
getInteger(String value)
Converts a string representation of an integer into an Integer object.
|
static Integer |
parseInteger(String value)
Utility method to convert a String to an Integer, and
handles null values.
|
static double |
truncate(double value,
double precision)
Utility method used to truncate a double to the given precision.
|
public static final Double DOUBLE_ZERO
public static final int getInt(Number value)
value - Number instancepublic static final int getInt(String value)
value - string representation of an integerpublic static final Integer getInteger(Number value)
value - Number instancepublic static final Integer getInteger(String value)
value - String representation of an integerpublic static final BigInteger getBigInteger(Number value)
value - Number instancepublic static final double getDouble(Number value)
value - Number instancepublic static final Double getDouble(double value)
value - Number instancepublic static final double truncate(double value,
double precision)
value - value to truncateprecision - Number of decimals to truncate to.public static final Integer parseInteger(String value)
value - string representation of an integerpublic static boolean equals(Number lhs, Number rhs)
lhs - left hand argumentrhs - right hand argumentpublic static boolean equals(double lhs,
double rhs,
double delta)
lhs - value to testrhs - value to testdelta - allowable differenceCopyright © 2013. All Rights Reserved.