Package org.apfloat.calc
Class AbstractCalculatorImpl
java.lang.Object
org.apfloat.calc.AbstractCalculatorImpl
- All Implemented Interfaces:
Serializable,CalculatorImpl
- Direct Known Subclasses:
FunctionCalculatorImpl
Basic calculator implementation.
Provides a storage for variables, and maps
the elementary operators to function calls.
- Version:
- 1.14.0
- Author:
- Mikko Tommila
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAddition.Division.Double factorial.Factorial.protected booleanGet the formatting option.protected LongGet the input precision.getVariable(String name) Get a variable.Remainder.Multiplication.Negative value.Power.voidsetFormat(boolean pretty) Set the formatting option.voidsetInputPrecision(Long inputPrecision) Set a fixed input precision.voidsetVariable(String name, Number value) Set a variable.Subtraction.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apfloat.calc.CalculatorImpl
format, function, parseDecimal, parseInteger
-
Constructor Details
-
AbstractCalculatorImpl
protected AbstractCalculatorImpl()Default constructor.
-
-
Method Details
-
negate
Description copied from interface:CalculatorImplNegative value.- Specified by:
negatein interfaceCalculatorImpl- Parameters:
x- The argument.- Returns:
-x- Throws:
ParseException- In case of invalid argument.
-
add
Description copied from interface:CalculatorImplAddition.- Specified by:
addin interfaceCalculatorImpl- Parameters:
x- First argument.y- Second argument.- Returns:
x + y- Throws:
ParseException- In case of invalid arguments.
-
subtract
Description copied from interface:CalculatorImplSubtraction.- Specified by:
subtractin interfaceCalculatorImpl- Parameters:
x- First argument.y- Second argument.- Returns:
x - y- Throws:
ParseException- In case of invalid arguments.
-
multiply
Description copied from interface:CalculatorImplMultiplication.- Specified by:
multiplyin interfaceCalculatorImpl- Parameters:
x- First argument.y- Second argument.- Returns:
x * y- Throws:
ParseException- In case of invalid arguments.
-
divide
Description copied from interface:CalculatorImplDivision.- Specified by:
dividein interfaceCalculatorImpl- Parameters:
x- First argument.y- Second argument.- Returns:
x / y- Throws:
ParseException- In case of invalid arguments.
-
mod
Description copied from interface:CalculatorImplRemainder.- Specified by:
modin interfaceCalculatorImpl- Parameters:
x- First argument.y- Second argument.- Returns:
x % y- Throws:
ParseException- In case of invalid arguments.
-
pow
Description copied from interface:CalculatorImplPower.- Specified by:
powin interfaceCalculatorImpl- Parameters:
x- First argument.y- Second argument.- Returns:
xy- Throws:
ParseException- In case of invalid arguments.
-
factorial
Description copied from interface:CalculatorImplFactorial.- Specified by:
factorialin interfaceCalculatorImpl- Parameters:
x- The argument.- Returns:
x!- Throws:
ParseException- In case of invalid arguments.
-
doubleFactorial
Description copied from interface:CalculatorImplDouble factorial.- Specified by:
doubleFactorialin interfaceCalculatorImpl- Parameters:
x- The argument.- Returns:
x!!- Throws:
ParseException- In case of invalid arguments.
-
getVariable
Description copied from interface:CalculatorImplGet a variable.- Specified by:
getVariablein interfaceCalculatorImpl- Parameters:
name- Name of the variable.- Returns:
- Value of the variable, or
nullif the variable is not defined. - Throws:
ParseException- In case of invalid argument.
-
setVariable
Description copied from interface:CalculatorImplSet a variable.- Specified by:
setVariablein interfaceCalculatorImpl- Parameters:
name- Name of the variable.value- Value of the variable.
-
setFormat
public void setFormat(boolean pretty) Description copied from interface:CalculatorImplSet the formatting option.- Specified by:
setFormatin interfaceCalculatorImpl- Parameters:
pretty- If a fixed-point or a floating-point notation should be used.
-
setInputPrecision
Description copied from interface:CalculatorImplSet a fixed input precision.- Specified by:
setInputPrecisionin interfaceCalculatorImpl- Parameters:
inputPrecision- The precision if a fixed precision is used ornullfor arbitrary precision.
-
getFormat
protected boolean getFormat()Get the formatting option.- Returns:
- If a fixed-point or a floating-point notation should be used.
-
getInputPrecision
Get the input precision.- Returns:
- The input precision if a fixed precision is used or
nullfor arbitrary precision.
-