# Interface CalculatorImpl

All Known Implementing Classes:
  `AbstractCalculatorImpl, ApfloatCalculatorImpl, FunctionCalculatorImpl`

public interface CalculatorImpl
Calculator implementation interface. The calculator parser uses this interface to perform the actual calculations.

Version:
  1.14.0
Author:
  Mikko Tommila

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Number`
  `add(Number x, Number y)`
  Addition.
  `Number`
  `divide(Number x, Number y)`
  Division.
  `Number`
  `doubleFactorial(Number x)`
  Double factorial.
  `Number`
  `factorial(Number x)`
  Factorial.
  `String`
  `format(Number x)`
  Convert a number to a String.
  `Number`
  `function(String name, List<Number> arguments)`
  Arbitrary function.
  `Number`
  `getVariable(String name)`
  Get a variable.
  `Number`
  `mod(Number x, Number y)`
  Remainder.
  `Number`
  `multiply(Number x, Number y)`
  Multiplication.
  `Number`
  `negate(Number x)`
  Negative value.
  `Number`
  `parseDecimal(String value)`
  Parse a string to a floating-point number.
  `Number`
  `parseInteger(String value)`
  Parse a string to an integer number.
  `Number`
  `pow(Number x, Number y)`
  Power.
  `void`
  `setFormat(boolean pretty)`
  Set the formatting option.
  `void`
  `setInputPrecision(Long inputPrecision)`
  Set a fixed input precision.
  `void`
  `setVariable(String name, Number value)`
  Set a variable.
  `Number`
  `subtract(Number x, Number y)`
  Subtraction.

- ## Method Details

  - ### negate

    Number negate(Number x) throws ParseException
    Negative value.
    Parameters:
      `x` - The argument.
    Returns:
      `-x`
    Throws:
      `ParseException` - In case of invalid argument.

  - ### add

    Number add(Number x, Number y) throws ParseException
    Addition.
    Parameters:
      `x` - First argument.
      `y` - Second argument.
    Returns:
      `x + y`
    Throws:
      `ParseException` - In case of invalid arguments.

  - ### subtract

    Number subtract(Number x, Number y) throws ParseException
    Subtraction.
    Parameters:
      `x` - First argument.
      `y` - Second argument.
    Returns:
      `x - y`
    Throws:
      `ParseException` - In case of invalid arguments.

  - ### multiply

    Number multiply(Number x, Number y) throws ParseException
    Multiplication.
    Parameters:
      `x` - First argument.
      `y` - Second argument.
    Returns:
      `x * y`
    Throws:
      `ParseException` - In case of invalid arguments.

  - ### divide

    Number divide(Number x, Number y) throws ParseException
    Division.
    Parameters:
      `x` - First argument.
      `y` - Second argument.
    Returns:
      `x / y`
    Throws:
      `ParseException` - In case of invalid arguments.

  - ### mod

    Number mod(Number x, Number y) throws ParseException
    Remainder.
    Parameters:
      `x` - First argument.
      `y` - Second argument.
    Returns:
      `x % y`
    Throws:
      `ParseException` - In case of invalid arguments.

  - ### pow

    Number pow(Number x, Number y) throws ParseException
    Power.
    Parameters:
      `x` - First argument.
      `y` - Second argument.
    Returns:
      `xy`
    Throws:
      `ParseException` - In case of invalid arguments.

  - ### factorial

    Number factorial(Number x) throws ParseException
    Factorial.
    Parameters:
      `x` - The argument.
    Returns:
      `x!`
    Throws:
      `ParseException` - In case of invalid arguments.

  - ### doubleFactorial

    Number doubleFactorial(Number x) throws ParseException
    Double factorial.
    Parameters:
      `x` - The argument.
    Returns:
      `x!!`
    Throws:
      `ParseException` - In case of invalid arguments.

  - ### function

    Number function(String name, List<Number> arguments) throws ParseException
    Arbitrary function.
    Parameters:
      `name` - Name of the function.
      `arguments` - Function arguments.
    Returns:
      Function value.
    Throws:
      `ParseException` - In case of invalid arguments.

  - ### parseInteger

    Number parseInteger(String value) throws ParseException
    Parse a string to an integer number.
    Parameters:
      `value` - The string to parse.
    Returns:
      The number.
    Throws:
      `ParseException` - In case of invalid number.

  - ### parseDecimal

    Number parseDecimal(String value) throws ParseException
    Parse a string to a floating-point number.
    Parameters:
      `value` - The string to parse.
    Returns:
      The number.
    Throws:
      `ParseException` - In case of invalid number.

  - ### getVariable

    Number getVariable(String name) throws ParseException
    Get a variable.
    Parameters:
      `name` - Name of the variable.
    Returns:
      Value of the variable, or `null` if the variable is not defined.
    Throws:
      `ParseException` - In case of invalid argument.

  - ### setVariable

    void setVariable(String name, Number value) throws ParseException
    Set a variable.
    Parameters:
      `name` - Name of the variable.
      `value` - Value of the variable.
    Throws:
      `ParseException` - In case of invalid arguments.

  - ### setFormat

    void setFormat(boolean pretty)
    Set the formatting option.
    Parameters:
      `pretty` - If a fixed-point or a floating-point notation should be used.

  - ### setInputPrecision

    void setInputPrecision(Long inputPrecision)
    Set a fixed input precision.
    Parameters:
      `inputPrecision` - The precision if a fixed precision is used or `null` for arbitrary precision.

  - ### format

    String format(Number x)
    Convert a number to a String. The current formatting option is used.
    Parameters:
      `x` - The number.
    Returns:
      The String.