|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jopendocument.util.NumberUtils
public class NumberUtils
Constructor Summary | |
---|---|
NumberUtils()
|
Method Summary | ||
---|---|---|
static
|
areEqual(N n1,
N n2)
Test class and numerical equality. |
|
static boolean |
areNumericallyEqual(Number n1,
Number n2)
Test numerical equality (but ignore class). |
|
static int |
compare(Number n1,
Number n2)
Compare two arbitrary numbers. |
|
static Number |
divide(Number n,
double d)
High precision divide. |
|
static Class<? extends Number> |
getWiderClass(Number n1,
Number n2)
Return a class wide enough for both numbers. |
|
static boolean |
hasFractionalPart(Number n)
Whether n has a non-zero fractional part. |
|
static int |
intDigits(long l)
|
|
static int |
intDigits(Number n)
The number of digits of the integer part in decimal representation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NumberUtils()
Method Detail |
---|
public static final <N extends Number> boolean areEqual(N n1, N n2)
BigDecimal.equals(Object)
also tests the
scale.
N
- type of number.n1
- first number, can be null
.n2
- second number, can be null
.
true
if n1
and n2
have the same class and are
numerically equal.areNumericallyEqual(Number, Number)
public static final boolean areNumericallyEqual(Number n1, Number n2)
n1
- first number, can be null
.n2
- second number, can be null
.
true
if n1
and n2
are numerically equal.compare(Number, Number)
public static final int compare(Number n1, Number n2)
n1
- first number, not null
.n2
- second number, not null
.
Comparable.compareTo(Object)
public static final Class<? extends Number> getWiderClass(Number n1, Number n2)
n1
- first number, not null
.n2
- second number, not null
.
NumberConvertor.convertExact(Number, Class)
public static final boolean hasFractionalPart(Number n)
n
has a non-zero fractional part.
n
- a number.
true
if there is a non-zero fractional part, e.g. true
for
1.3d and false
for new BigDecimal("1.00")
.public static final int intDigits(long l)
public static final int intDigits(Number n)
n
- a number, e.g. 123.45.
public static Number divide(Number n, double d)
n
- the dividend.d
- the divisor.
n / d
.DecimalUtils.HIGH_PRECISION
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |