Package com.singularsys.jep.bigdecimal
Class BigDecComponents
java.lang.Object
com.singularsys.jep.ComponentSet
com.singularsys.jep.bigdecimal.BigDecComponents
- All Implemented Interfaces:
FixedPrecisionFunctionI
A set of components for working with big decimal numbers.
It can be set up in a number of ways:
- With unlimited precision, some operators like division will fail
- Using a
MathContextspecifying the number of significant figures, and rounding mode. - Fixed-point setup, with a specified number of decimal places to use for all results.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs the class using theMathContext.UNLIMITEDfor unlimited precision arithmetic.BigDecComponents(int scale) Fixed precision setup, with a specified number of decimal places.Constructs the class with the specific math context.BigDecComponents(MathContext mc, boolean allowStrings) Setup with string supportBigDecComponents(MathContext mc, int scale, boolean allowStrings) Fixed precision setup with a specific MathContext and optional string support. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether string are allowedintGet the scale used for fixed precision numbersvoidsetAllowStrings(boolean allowStrings) Sets whether BigDecimals and strings can be used together.voidsetDecimalPlaces(int scale) Set the scale used for fixed precision numbersvoidMethods inherited from class com.singularsys.jep.ComponentSet
addAuxComponent, addComponents, findOrElse, getAuxComponents, getAuxComps, getBaseComponents, getComponents, getEvaluator, getFunctionTable, getNodeFactory, getNumberFactory, getOperatorTable, getParser, getPrintVisitor, getVariableFactory, getVariableTable, setAuxComps, setEvaluator, setFunctionTable, setNodeFactory, setNumberFactory, setOperatorTable, setParser, setPrintVisitor, setVariableFactory, setVariableTable
-
Field Details
-
mc
-
scale
protected int scale -
allowStrings
protected boolean allowStrings
-
-
Constructor Details
-
BigDecComponents
public BigDecComponents()Constructs the class using theMathContext.UNLIMITEDfor unlimited precision arithmetic. -
BigDecComponents
Constructs the class with the specific math context. The math context is passed the number factory, function table, and operator table constructors.- Parameters:
mc- the math context for the components.
-
BigDecComponents
public BigDecComponents(int scale) Fixed precision setup, with a specified number of decimal places. Uses unlimited precision with the rounding mode half-even.- Parameters:
scale- number of decimal digits should be greater or equal to zero.- Since:
- Jep 4.1
-
BigDecComponents
Fixed precision setup with a specific MathContext and optional string support.- Parameters:
mc- specifying the precision and rounding mode used.scale- number of decimal digits should be greater or equal to zero.allowStrings- whether string are allowed- Since:
- Jep 4.1
-
BigDecComponents
Setup with string support- Parameters:
mc- The mathContext to useallowStrings- whether string are allowed
-
-
Method Details
-
getMathContext
-
setMathContext
-
setAllowStrings
public void setAllowStrings(boolean allowStrings) Sets whether BigDecimals and strings can be used together.- Parameters:
allowStrings-- Since:
- 3.4.0
-
getAllowStrings
public boolean getAllowStrings()Whether string are allowed- Returns:
- true is string can be used
- Since:
- 3.4.0
-
setDecimalPlaces
public void setDecimalPlaces(int scale) Set the scale used for fixed precision numbers- Specified by:
setDecimalPlacesin interfaceFixedPrecisionFunctionI- Parameters:
scale- number of decimal digits should be greater or equal to zero.- Since:
- Jep 4.1
-
getDecimalPlaces
public int getDecimalPlaces()Get the scale used for fixed precision numbers- Specified by:
getDecimalPlacesin interfaceFixedPrecisionFunctionI- Returns:
- number of decimal digits or -1 if not using fixed precision
- Since:
- Jep 4.1
-