|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectariba.util.core.Arithmetic
public abstract class Arithmetic
Arithmetic is an abstract class that encapsulates the idea of doing simple
arithmetic operations on instances of the sub-types of
java.lang.Number.
IntegerArithmetic does integer arithmetic on the
Numbers passed to it via the Number.intValue()
method.
| Nested Class Summary | |
|---|---|
static class |
Arithmetic.Operation
Enumeration class capturing binary operations on instances of java.lang.Number. |
| Field Summary | |
|---|---|
static Arithmetic |
BigDecimalArithmetic
|
static int |
BigDecimalType
Represents the BigDecimal type. |
static Arithmetic |
BigIntegerArithmetic
|
static int |
BigIntegerType
Represents the BigInteger type. |
static int |
ByteType
Represents the Byte type. |
static Arithmetic |
DoubleArithmetic
|
static int |
DoubleType
Represents the Double type. |
static int |
FloatType
Represents the Float type. |
static Arithmetic |
IntegerArithmetic
|
static int |
IntegerType
Represents the Integer type. |
static Arithmetic |
LongArithmetic
|
static int |
LongType
Represents the Long type. |
static int |
ShortType
Represents the Short type. |
| Constructor Summary | |
|---|---|
Arithmetic()
|
|
| Method Summary | |
|---|---|
abstract Number |
add(Number first,
Number second)
Adds first and second and returns the result. |
static BigDecimal |
asBigDecimal(Number number)
|
static BigInteger |
asBigInteger(Number number)
|
abstract int |
compare(Number first,
Number second)
Compares first and second and returns the result. |
abstract Number |
divide(Number first,
Number second)
Divides first by second and returns the result. |
Number |
evaluate(Number first,
Arithmetic.Operation operation,
Number second)
Evaluates first and second with respect to
operation which must be one of:
OpAdd, OpSubtract, OpMultiply, OpDivide. |
static Arithmetic |
getArithmeticFromNumberType(int numberType)
Returns the Arithmetic instance corresponding to the
supplied numberType. |
static int |
getNumberType(Number number)
Returns one of the constants representing |
abstract Number |
multiply(Number first,
Number second)
Multiplies first by second and returns the result. |
static Number |
negate(Number number)
|
abstract Number |
subtract(Number first,
Number second)
Subtracts second from first and
returns the result. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int ByteType
Byte type.
public static final int ShortType
Short type.
public static final int IntegerType
Integer type.
public static final int LongType
Long type.
public static final int FloatType
Float type.
public static final int DoubleType
Double type.
public static final int BigIntegerType
BigInteger type.
public static final int BigDecimalType
BigDecimal type.
public static final Arithmetic IntegerArithmetic
public static final Arithmetic LongArithmetic
public static final Arithmetic DoubleArithmetic
public static final Arithmetic BigIntegerArithmetic
public static final Arithmetic BigDecimalArithmetic
| Constructor Detail |
|---|
public Arithmetic()
| Method Detail |
|---|
public abstract Number add(Number first,
Number second)
first and second and returns the result.
public abstract Number subtract(Number first,
Number second)
second from first and
returns the result.
public abstract Number multiply(Number first,
Number second)
first by second and returns the result.
public abstract Number divide(Number first,
Number second)
first by second and returns the result.
public abstract int compare(Number first,
Number second)
first and second and returns the result.
public final Number evaluate(Number first,
Arithmetic.Operation operation,
Number second)
first and second with respect to
operation which must be one of:
OpAdd, OpSubtract, OpMultiply, OpDivide.
public static BigInteger asBigInteger(Number number)
public static BigDecimal asBigDecimal(Number number)
public static int getNumberType(Number number)
public static Arithmetic getArithmeticFromNumberType(int numberType)
Arithmetic instance corresponding to the
supplied numberType.
public static Number negate(Number number)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||