Package com.singularsys.jep.bigdecimal

# Class BigDecComponents

java.lang.Object
com.singularsys.jep.ComponentSet
com.singularsys.jep.bigdecimal.BigDecComponents

All Implemented Interfaces:
  `FixedPrecisionFunctionI`

public class BigDecComponents extends ComponentSet implements 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 `MathContext` specifying the number of significant figures, and rounding mode.
- Fixed-point setup, with a specified number of decimal places to use for all results.

In addition the components can be setup to allow addition and comparison of strings. Comparison and logical operators also work with Booleans.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected boolean`
  `allowStrings`
  `protected MathContext`
  `mc`
  `protected int`
  `scale`

  ### Fields inherited from class com.singularsys.jep.ComponentSet

  `auxComps, evaluator, funTab, nodeFac, numFac, opTab, parser, pv, varFac, varTab`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BigDecComponents()`
  Constructs the class using the `MathContext.UNLIMITED` for unlimited precision arithmetic.
  `BigDecComponents(int scale)`
  Fixed precision setup, with a specified number of decimal places.
  `BigDecComponents(MathContext mc)`
  Constructs the class with the specific math context.
  `BigDecComponents(MathContext mc, boolean allowStrings)`
  Setup with string support
  `BigDecComponents(MathContext mc, int scale, boolean allowStrings)`
  Fixed precision setup with a specific MathContext and optional string support.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `getAllowStrings()`
  Whether string are allowed
  `int`
  `getDecimalPlaces()`
  Get the scale used for fixed precision numbers
  `MathContext`
  `getMathContext()`
  `void`
  `setAllowStrings(boolean allowStrings)`
  Sets whether BigDecimals and strings can be used together.
  `void`
  `setDecimalPlaces(int scale)`
  Set the scale used for fixed precision numbers
  `void`
  `setMathContext(MathContext mc)`

  ### Methods 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`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### mc

    protected MathContext mc

  - ### scale

    protected int scale

  - ### allowStrings

    protected boolean allowStrings

- ## Constructor Details

  - ### BigDecComponents

    public BigDecComponents()
    Constructs the class using the `MathContext.UNLIMITED` for unlimited precision arithmetic.

  - ### BigDecComponents

    public BigDecComponents(MathContext mc)
    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

    public BigDecComponents(MathContext mc, int scale, boolean allowStrings)
    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

    public BigDecComponents(MathContext mc, boolean allowStrings)
    Setup with string support
    Parameters:
      `mc` - The mathContext to use
      `allowStrings` - whether string are allowed

- ## Method Details

  - ### getMathContext

    public MathContext getMathContext()

  - ### setMathContext

    public void setMathContext(MathContext mc)

  - ### 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:
      `setDecimalPlaces` in interface `FixedPrecisionFunctionI`
    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:
      `getDecimalPlaces` in interface `FixedPrecisionFunctionI`
    Returns:
      number of decimal digits or -1 if not using fixed precision
    Since:
      Jep 4.1