Class BigDecimalField
- java.lang.Object
-
- com.singularsys.extensions.field.implementations.AbstractComparativeField
-
- com.singularsys.extensions.field.implementations.GenericField<java.math.BigDecimal>
-
- com.singularsys.extensions.field.implementations.BigDecimalField
-
- All Implemented Interfaces:
FieldI,IntegerConvertor,java.io.Serializable
public class BigDecimalField extends GenericField<java.math.BigDecimal>
Implementation of field methods using BigDecimals- Author:
- Richard Morris
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BigDecimalField(java.math.MathContext mc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigDecimaladdG(java.math.BigDecimal l, java.math.BigDecimal r)Adds two elements of type E.java.math.BigDecimalcast(java.lang.Object l)Convert the input to type E.java.lang.IntegercmpG(java.math.BigDecimal l, java.math.BigDecimal r)Compare two objects of the same type.java.math.BigDecimalconvertFromInt(java.lang.Integer l)Attempt to convert argument from an integerjava.lang.IntegerconvertToIntE(java.math.BigDecimal l)If possible convert the argument to an Integer to enable integral powers.java.math.BigDecimaldivG(java.math.BigDecimal l, java.math.BigDecimal r)Divides two elements of type E.java.math.BigDecimalgetOne()Get the multiplicative identity for this field.java.math.BigDecimalgetZero()Get the additive identity for this fieldjava.math.BigDecimalmodG(java.math.BigDecimal l, java.math.BigDecimal r)Modulus of two elements of type E.java.math.BigDecimalmulG(java.math.BigDecimal l, java.math.BigDecimal r)Multiplies two elements of type E.java.math.BigDecimalnegG(java.math.BigDecimal l)Negates an elements of type E.java.math.BigDecimalpowG(java.math.BigDecimal l, java.math.BigDecimal r)Only integral values are allowed.java.math.BigDecimalsubG(java.math.BigDecimal l, java.math.BigDecimal r)Subtracts two elements of type E.-
Methods inherited from class com.singularsys.extensions.field.implementations.GenericField
add, and, cmp, convertToInt, div, mod, mul, neg, not, or, pow, sub
-
-
-
-
Method Detail
-
cast
public java.math.BigDecimal cast(java.lang.Object l)
Description copied from class:GenericFieldConvert the input to type E.- Specified by:
castin classGenericField<java.math.BigDecimal>- Returns:
- l if l is a BigDecimal, null otherwise
-
addG
public java.math.BigDecimal addG(java.math.BigDecimal l, java.math.BigDecimal r) throws EvaluationExceptionDescription copied from class:GenericFieldAdds two elements of type E.- Specified by:
addGin classGenericField<java.math.BigDecimal>- Parameters:
l- lhs argumentr- rhs argument- Returns:
- the sum
- Throws:
EvaluationException- on error
-
subG
public java.math.BigDecimal subG(java.math.BigDecimal l, java.math.BigDecimal r) throws EvaluationExceptionDescription copied from class:GenericFieldSubtracts two elements of type E.- Specified by:
subGin classGenericField<java.math.BigDecimal>- Parameters:
l- lhs argumentr- rhs argument- Returns:
- the difference
- Throws:
EvaluationException- on error
-
negG
public java.math.BigDecimal negG(java.math.BigDecimal l) throws EvaluationExceptionDescription copied from class:GenericFieldNegates an elements of type E.- Specified by:
negGin classGenericField<java.math.BigDecimal>- Parameters:
l- the argument- Returns:
- the negation
- Throws:
EvaluationException- on error
-
mulG
public java.math.BigDecimal mulG(java.math.BigDecimal l, java.math.BigDecimal r) throws EvaluationExceptionDescription copied from class:GenericFieldMultiplies two elements of type E.- Specified by:
mulGin classGenericField<java.math.BigDecimal>- Parameters:
l- lhs argumentr- rhs argument- Returns:
- the product
- Throws:
EvaluationException- on error
-
divG
public java.math.BigDecimal divG(java.math.BigDecimal l, java.math.BigDecimal r) throws EvaluationExceptionDescription copied from class:GenericFieldDivides two elements of type E.- Specified by:
divGin classGenericField<java.math.BigDecimal>- Parameters:
l- numeratorr- denominator- Returns:
- the division
- Throws:
EvaluationException- on error
-
modG
public java.math.BigDecimal modG(java.math.BigDecimal l, java.math.BigDecimal r) throws EvaluationExceptionDescription copied from class:GenericFieldModulus of two elements of type E.- Specified by:
modGin classGenericField<java.math.BigDecimal>- Parameters:
l- lhs argumentr- rhs argument- Returns:
- the modulus
- Throws:
EvaluationException- on error
-
powG
public java.math.BigDecimal powG(java.math.BigDecimal l, java.math.BigDecimal r) throws EvaluationExceptionOnly integral values are allowed.- Specified by:
powGin classGenericField<java.math.BigDecimal>- Parameters:
l- lhs argumentr- rhs argument- Returns:
- the power
- Throws:
EvaluationException- for non integral values.
-
cmpG
public java.lang.Integer cmpG(java.math.BigDecimal l, java.math.BigDecimal r) throws EvaluationExceptionDescription copied from class:GenericFieldCompare two objects of the same type.- Specified by:
cmpGin classGenericField<java.math.BigDecimal>- Parameters:
l- left argumentr- right argument- Returns:
- -1, 0, 1 or null
- Throws:
EvaluationException
-
getOne
public java.math.BigDecimal getOne()
Description copied from interface:FieldIGet the multiplicative identity for this field.- Specified by:
getOnein interfaceFieldI- Specified by:
getOnein classGenericField<java.math.BigDecimal>- Returns:
- object representing one or null if undefined for this field
-
getZero
public java.math.BigDecimal getZero()
Description copied from interface:FieldIGet the additive identity for this field- Specified by:
getZeroin interfaceFieldI- Specified by:
getZeroin classGenericField<java.math.BigDecimal>- Returns:
- object representing zero or null if undefined for this field
-
convertFromInt
public java.math.BigDecimal convertFromInt(java.lang.Integer l) throws EvaluationExceptionDescription copied from interface:IntegerConvertorAttempt to convert argument from an integer- Specified by:
convertFromIntin interfaceIntegerConvertor- Specified by:
convertFromIntin classGenericField<java.math.BigDecimal>- Parameters:
l- value to convert- Returns:
- corresponding value in this field or null if it cannot be converted
- Throws:
EvaluationException- probably never
-
convertToIntE
public java.lang.Integer convertToIntE(java.math.BigDecimal l) throws EvaluationExceptionDescription copied from class:GenericFieldIf possible convert the argument to an Integer to enable integral powers. If the argument cannot be converted null should be returned and thepowG(E,E)method will be called.- Specified by:
convertToIntEin classGenericField<java.math.BigDecimal>- Parameters:
l- argument to convert.- Returns:
- an integer or null if argument cannot be converted
- Throws:
EvaluationException
-
-