Package tech.units.indriya.function
Class DefaultNumberSystem
- java.lang.Object
-
- tech.units.indriya.function.DefaultNumberSystem
-
- All Implemented Interfaces:
NumberSystem
public class DefaultNumberSystem extends Object implements NumberSystem
- Since:
- 2.0
- Author:
- Andi Huber, Werner Keil
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface tech.units.indriya.spi.NumberSystem
NumberSystem.DivisionResult
-
-
Constructor Summary
Constructors Constructor Description DefaultNumberSystem()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Numberabs(Number number)Returns the absolute of givennumberas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.Numberadd(Number x, Number y)Returns the sum of givenxandyas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.intcompare(Number x, Number y)Compares twoNumbervalues numerically.Numberdivide(Number x, Number y)Returns the division of givenxandyas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.Number[]divideAndRemainder(Number x, Number y, boolean roundRemainderTowardsZero)Returns a two-element Number array containing {x / y, x % y}Numberexp(Number number)Returns Euler's Constant to the power of of givennumberas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.booleanisInteger(Number number)Checks whether givennumberhas fractional parts or not.booleanisLessThanOne(Number number)booleanisOne(Number number)booleanisZero(Number number)Numberlog(Number number)Returns the natural logarithm of givennumberas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.Numbermultiply(Number x, Number y)Returns the product of givenxandyas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.Numbernarrow(Number number)'Narrows' givennumberas aNumberthat best represents the numeric value within the set of number types this NumberSystem supports.Numbernegate(Number number)Returns the negation of givennumberas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.Numberpower(Number number, int exponent)Returns givennumberto the power ofexponentas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.Numberreciprocal(Number number)Returns the reciprocal of givennumberas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.intsignum(Number number)Returns the signum function of givennumber.Numbersubtract(Number x, Number y)Returns the difference of givenxandyas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface tech.units.indriya.spi.NumberSystem
equals
-
-
-
-
Constructor Detail
-
DefaultNumberSystem
public DefaultNumberSystem()
-
-
Method Detail
-
add
public Number add(Number x, Number y)
Description copied from interface:NumberSystemReturns the sum of givenxandyas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.- Specified by:
addin interfaceNumberSystem- Returns:
x + y
-
subtract
public Number subtract(Number x, Number y)
Description copied from interface:NumberSystemReturns the difference of givenxandyas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.- Specified by:
subtractin interfaceNumberSystem- Returns:
x - y
-
multiply
public Number multiply(Number x, Number y)
Description copied from interface:NumberSystemReturns the product of givenxandyas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.- Specified by:
multiplyin interfaceNumberSystem- Returns:
x * y
-
divide
public Number divide(Number x, Number y)
Description copied from interface:NumberSystemReturns the division of givenxandyas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.- Specified by:
dividein interfaceNumberSystem- Returns:
x / y
-
divideAndRemainder
public Number[] divideAndRemainder(Number x, Number y, boolean roundRemainderTowardsZero)
Description copied from interface:NumberSystemReturns a two-element Number array containing {x / y, x % y}- Specified by:
divideAndRemainderin interfaceNumberSystemroundRemainderTowardsZero- - whether the division remainder should be rounded towards zero- Returns:
-
reciprocal
public Number reciprocal(Number number)
Description copied from interface:NumberSystemReturns the reciprocal of givennumberas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.- Specified by:
reciprocalin interfaceNumberSystem- Returns:
number^-1
-
signum
public int signum(Number number)
Description copied from interface:NumberSystemReturns the signum function of givennumber.- Specified by:
signumin interfaceNumberSystem- Returns:
signum(number)
-
abs
public Number abs(Number number)
Description copied from interface:NumberSystemReturns the absolute of givennumberas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.- Specified by:
absin interfaceNumberSystem- Returns:
abs(number)
-
negate
public Number negate(Number number)
Description copied from interface:NumberSystemReturns the negation of givennumberas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.- Specified by:
negatein interfaceNumberSystem- Returns:
-number
-
power
public Number power(Number number, int exponent)
Description copied from interface:NumberSystemReturns givennumberto the power ofexponentas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.- Specified by:
powerin interfaceNumberSystemexponent- - an integer- Returns:
- number^exponent
-
exp
public Number exp(Number number)
Description copied from interface:NumberSystemReturns Euler's Constant to the power of of givennumberas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.- Specified by:
expin interfaceNumberSystem- Returns:
e^number, witheEuler's Constant)
-
log
public Number log(Number number)
Description copied from interface:NumberSystemReturns the natural logarithm of givennumberas aNumberthat best represents the arithmetic result within the set of number types this NumberSystem supports.- Specified by:
login interfaceNumberSystem- Returns:
- natural logarithm of number
-
narrow
public Number narrow(Number number)
Description copied from interface:NumberSystem'Narrows' givennumberas aNumberthat best represents the numeric value within the set of number types this NumberSystem supports.eg. A BigInteger that is within range of Java's
Longtype can be narrowed to Long w/o loss of precision.- Specified by:
narrowin interfaceNumberSystem- Returns:
- 'best' representation of
numberw/o loss of precision
-
compare
public int compare(Number x, Number y)
Description copied from interface:NumberSystemCompares twoNumbervalues numerically.- Specified by:
comparein interfaceNumberSystem- Returns:
- the value
0ifx == y; a value less than0ifx < y; and a value greater than0ifx > y
-
isZero
public boolean isZero(Number number)
- Specified by:
isZeroin interfaceNumberSystem
-
isOne
public boolean isOne(Number number)
- Specified by:
isOnein interfaceNumberSystem
-
isLessThanOne
public boolean isLessThanOne(Number number)
- Specified by:
isLessThanOnein interfaceNumberSystem
-
isInteger
public boolean isInteger(Number number)
Description copied from interface:NumberSystemChecks whether givennumberhas fractional parts or not.- Specified by:
isIntegerin interfaceNumberSystem- Returns:
- whether
numberrepresents a whole number
-
-