Package com.singularsys.jep.bigdecimal

# Class BigDecFunctionTable

java.lang.Object
com.singularsys.jep.FunctionTable
com.singularsys.jep.bigdecimal.BigDecFunctionTable

All Implemented Interfaces:
  `FixedPrecisionFunctionI`, `JepComponent`, `Serializable`

public class BigDecFunctionTable extends FunctionTable implements FixedPrecisionFunctionI
A function table for BigDecimals. Has a MathContext field which can be used by functions.

The table supplies the follow functions:

- `abs(x)` absolute value,
- `signum(x)` sign of the argument either 1, 0 or -1.
- `if(cond,x,y)` if statement,
- `rint(x)` round to nearest integer, , rint(x,n) with ties rounded to even numbers
- `rint(x,n)` round to n decimal places
- `round(x)` round to nearest integer, , rint(x,n) with ties rounded to positive infinity
- `round(x,n)` round to n decimal places
- `roundSF(x,n)` round x to n significant figures,
- `ceil(x)` round up to nearest integer value
- `floor(x)` round down to nearest integer value
- `sum` sum of arguments,
- `vsum` sum the elements of a vector,
- `avg` mean of the elements of a vector,
- `min` minimum element of a vector,
- `max` maximum element of a vector,
- `count` number of the elements in a vector,

Version:
  Jep 3.5 Added min, max and various rounding functions.
See Also:
  - Serialized Form

- ## Field Summary

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

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

  `table`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  ``
  `BigDecFunctionTable(MathContext mc)`
  ``
  `BigDecFunctionTable(MathContext mc, int scale)`
  Fixed precision functions.
  `protected`
  `BigDecFunctionTable(MathContext mc, Map<String,PostfixMathCommandI> tbl)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getDecimalPlaces()`
  Gets the number of decimal places used.
  `MathContext`
  `getMathContext()`
  `void`
  `setDecimalPlaces(int scale)`
  Sets the number of decimal places to use.
  `void`
  `setMathContext(MathContext mc)`
  `FunctionTable`
  `shallowCopy()`
  Returns a new shallow copy of this function table.

  ### Methods inherited from class com.singularsys.jep.FunctionTable

  `addFunction, addFunctionIfSet, clear, containsKey, containsValue, copyFunctionsFrom, entrySet, getFunction, getLightWeightInstance, init, isEmpty, keySet, remove, size, threadSafeMapCopy, toString, values`

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

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

- ## Field Details

  - ### mc

    protected MathContext mc

  - ### scale

    protected int scale

- ## Constructor Details

  - ### BigDecFunctionTable

    public BigDecFunctionTable(MathContext mc)

  - ### BigDecFunctionTable

    public BigDecFunctionTable(MathContext mc, int scale)
    Fixed precision functions.
    Parameters:
      `mc` - MathContext, usually `MathContext.UNLIMITED`.
      `scale` - number of decimal digits should be greater or equal to zero.
    Since:
      Jep 4.1

  - ### BigDecFunctionTable

    protected BigDecFunctionTable(MathContext mc, Map<String,PostfixMathCommandI> tbl)

- ## Method Details

  - ### getMathContext

    public MathContext getMathContext()

  - ### setMathContext

    public void setMathContext(MathContext mc)

  - ### shallowCopy

    public FunctionTable shallowCopy()
    Description copied from class: `FunctionTable`
    Returns a new shallow copy of this function table. Calls the `FunctionTable.threadSafeMapCopy()` method to ensure the table is safe to use a separate thread. All subclasses should override this method to create a function table of the matching type. A typical implementation would be

         @Override
         public FunctionTable shallowCopy() {
             Map<String,PostfixMathCommandI> newMap = this.threadSafeMapCopy();
             return new myFunctionTable(newMap);
         }

    using the `FunctionTable.threadSafeMapCopy()` method to return a copy of the map of functions and a constructor taking this map which uses the `FunctionTable(Map)` constructor.
    Overrides:
      `shallowCopy` in class `FunctionTable`
    Returns:
      a new shallow copy of this function table

  - ### setDecimalPlaces

    public void setDecimalPlaces(int scale)
    Description copied from interface: `FixedPrecisionFunctionI`
    Sets the number of decimal places to use.
    Specified by:
      `setDecimalPlaces` in interface `FixedPrecisionFunctionI`
    Parameters:
      `scale` - either zero, a positive number or -1 for floating-point formats

  - ### getDecimalPlaces

    public int getDecimalPlaces()
    Description copied from interface: `FixedPrecisionFunctionI`
    Gets the number of decimal places used.
    Specified by:
      `getDecimalPlaces` in interface `FixedPrecisionFunctionI`
    Returns:
      either zero, a positive number or -1 for floating-point formats