public class Calculator extends Object
Number
s utilizing a provided NumberSystem
.Modifier and Type | Method | Description |
---|---|---|
Calculator |
abs() |
Calculates the absolute value of this
Calculator ´s accumulator,
then stores the result in the accumulator. |
Calculator |
add(Number number) |
Adds
number to this Calculator ´s accumulator,
then stores the result in the accumulator. |
Calculator |
divide(Number number) |
Divides this
Calculator ´s accumulator by number ,
then stores the result in the accumulator. |
Calculator |
exp() |
Calculates Euler's constant taken to the power of this
Calculator ´s accumulator,
then stores the result in the accumulator. |
protected static Calculator |
getInstance() |
Returns a new instance of a
Calculator initialized with the default NumberSystem ,
as set at Calculus.currentNumberSystem() |
boolean |
isLessThanOne() |
|
Calculator |
load(Number number) |
Loads
number into this Calculator ´s accumulator. |
Calculator |
log() |
Calculates the natural logarithm of this
Calculator ´s accumulator,
then stores the result in the accumulator. |
Calculator |
multiply(Number number) |
Multiplies
number with this Calculator ´s accumulator,
then stores the result in the accumulator. |
Calculator |
negate() |
Calculates the additive inverse value of this
Calculator ´s accumulator,
then stores the result in the accumulator. |
static Calculator |
of(Number number) |
Shortcut for
getDefault().load(number) . |
Number |
peek() |
Allows to 'peek' at this
Calculator ´s accumulator. |
Calculator |
power(int exponent) |
Takes this
Calculator ´s accumulator to the integer power of exponent ,
then stores the result in the accumulator. |
Calculator |
reciprocal() |
Calculates the multiplicative inverse value of this
Calculator ´s accumulator,
then stores the result in the accumulator. |
Calculator |
subtract(Number number) |
Subtracts
number from this Calculator ´s accumulator,
then stores the result in the accumulator. |
protected static Calculator getInstance()
Calculator
initialized with the default NumberSystem
,
as set at Calculus.currentNumberSystem()
This implementation is *not* thread-safe, hence threads should not share instances of this.
Calculator
initialized with the default NumberSystem
public static Calculator of(Number number)
number
- Calculator
with number
loaded into its accumulatorpublic Calculator load(Number number)
number
into this Calculator
´s accumulator.number
- public Calculator add(Number number)
number
to this Calculator
´s accumulator,
then stores the result in the accumulator.number
- public Calculator subtract(Number number)
number
from this Calculator
´s accumulator,
then stores the result in the accumulator.number
- public Calculator multiply(Number number)
number
with this Calculator
´s accumulator,
then stores the result in the accumulator.number
- public Calculator divide(Number number)
Calculator
´s accumulator by number
,
then stores the result in the accumulator.number
- public Calculator power(int exponent)
Calculator
´s accumulator to the integer power of exponent
,
then stores the result in the accumulator.exponent
- public Calculator abs()
Calculator
´s accumulator,
then stores the result in the accumulator.public Calculator negate()
Calculator
´s accumulator,
then stores the result in the accumulator.public Calculator reciprocal()
Calculator
´s accumulator,
then stores the result in the accumulator.public Calculator exp()
Calculator
´s accumulator,
then stores the result in the accumulator.public Calculator log()
Calculator
´s accumulator,
then stores the result in the accumulator.public Number peek()
Calculator
´s accumulator. The Number
returned is narrowed
to best represent the numerical value w/o loss of precision within the NumberSystem
as
configured for this Calculator
instance.Calculator
´s accumulatorpublic boolean isLessThanOne()
Calculator
´s accumulator is less than ONECopyright © 2005–2020 Units of Measurement project. All rights reserved.