Package org.apfloat.calc
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 TypeMethodDescriptionAddition.Division.Double factorial.Factorial.Convert a number to a String.Arbitrary function.getVariable
(String name) Get a variable.Remainder.Multiplication.Negative value.parseDecimal
(String value) Parse a string to a floating-point number.parseInteger
(String value) Parse a string to an integer number.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.Subtraction.
-
Method Details
-
negate
Negative value.- Parameters:
x
- The argument.- Returns:
-x
- Throws:
ParseException
- In case of invalid argument.
-
add
Addition.- Parameters:
x
- First argument.y
- Second argument.- Returns:
x + y
- Throws:
ParseException
- In case of invalid arguments.
-
subtract
Subtraction.- Parameters:
x
- First argument.y
- Second argument.- Returns:
x - y
- Throws:
ParseException
- In case of invalid arguments.
-
multiply
Multiplication.- Parameters:
x
- First argument.y
- Second argument.- Returns:
x * y
- Throws:
ParseException
- In case of invalid arguments.
-
divide
Division.- Parameters:
x
- First argument.y
- Second argument.- Returns:
x / y
- Throws:
ParseException
- In case of invalid arguments.
-
mod
Remainder.- Parameters:
x
- First argument.y
- Second argument.- Returns:
x % y
- Throws:
ParseException
- In case of invalid arguments.
-
pow
Power.- Parameters:
x
- First argument.y
- Second argument.- Returns:
xy
- Throws:
ParseException
- In case of invalid arguments.
-
factorial
Factorial.- Parameters:
x
- The argument.- Returns:
x!
- Throws:
ParseException
- In case of invalid arguments.
-
doubleFactorial
Double factorial.- Parameters:
x
- The argument.- Returns:
x!!
- Throws:
ParseException
- In case of invalid arguments.
-
function
Arbitrary function.- Parameters:
name
- Name of the function.arguments
- Function arguments.- Returns:
- Function value.
- Throws:
ParseException
- In case of invalid arguments.
-
parseInteger
Parse a string to an integer number.- Parameters:
value
- The string to parse.- Returns:
- The number.
- Throws:
ParseException
- In case of invalid number.
-
parseDecimal
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
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
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
Set a fixed input precision.- Parameters:
inputPrecision
- The precision if a fixed precision is used ornull
for arbitrary precision.
-
format
-