public class DefaultNumberSystem extends Object implements NumberSystem
NumberSystem.DivisionResult| Constructor and Description |
|---|
DefaultNumberSystem() |
| Modifier and Type | Method and Description |
|---|---|
Number |
abs(Number number)
Returns the absolute of given
number as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports. |
Number |
add(Number x,
Number y)
Returns the sum of given
x and y as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports. |
int |
compare(Number x,
Number y)
Compares two
Number values numerically. |
Number |
divide(Number x,
Number y)
Returns the division of given
x and y as a Number that 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}
|
Number |
exp(Number number)
Returns Euler's Constant to the power of of given
number as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports. |
boolean |
isInteger(Number number)
Checks whether given
number has fractional parts or not. |
boolean |
isLessThanOne(Number number) |
boolean |
isOne(Number number) |
boolean |
isZero(Number number) |
Number |
log(Number number)
Returns the natural logarithm of given
number as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports. |
Number |
multiply(Number x,
Number y)
Returns the product of given
x and y as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports. |
Number |
narrow(Number number)
'Narrows' given
number as a Number that best
represents the numeric value within the set of number types this NumberSystem
supports. |
Number |
negate(Number number)
Returns the negation of given
number as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports. |
Number |
power(Number number,
int exponent)
Returns given
number to the power of exponent as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports. |
Number |
reciprocal(Number number)
Returns the reciprocal of given
number as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports. |
int |
signum(Number number)
Returns the signum function of given
number. |
Number |
subtract(Number x,
Number y)
Returns the difference of given
x and y as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequalspublic DefaultNumberSystem()
public Number add(Number x, Number y)
NumberSystemx and y as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.add in interface NumberSystemx + ypublic Number subtract(Number x, Number y)
NumberSystemx and y as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.subtract in interface NumberSystemx - ypublic Number multiply(Number x, Number y)
NumberSystemx and y as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.multiply in interface NumberSystemx * ypublic Number divide(Number x, Number y)
NumberSystemx and y as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.divide in interface NumberSystemx / ypublic Number[] divideAndRemainder(Number x, Number y, boolean roundRemainderTowardsZero)
NumberSystemdivideAndRemainder in interface NumberSystemroundRemainderTowardsZero - - whether the division remainder should be rounded towards zeropublic Number reciprocal(Number number)
NumberSystemnumber as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.reciprocal in interface NumberSystemnumber^-1public int signum(Number number)
NumberSystemnumber.signum in interface NumberSystemsignum(number)public Number abs(Number number)
NumberSystemnumber as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.abs in interface NumberSystemabs(number)public Number negate(Number number)
NumberSystemnumber as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.negate in interface NumberSystem-numberpublic Number power(Number number, int exponent)
NumberSystemnumber to the power of exponent as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.power in interface NumberSystemexponent - - an integerpublic Number exp(Number number)
NumberSystemnumber as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.exp in interface NumberSysteme^number, with e Euler's Constant)public Number log(Number number)
NumberSystemnumber as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.log in interface NumberSystempublic Number narrow(Number number)
NumberSystemnumber as a Number that best
represents the numeric value within the set of number types this NumberSystem
supports.
eg. A BigInteger that is within range of Java's Long type can be narrowed to
Long w/o loss of precision.
narrow in interface NumberSystemnumber w/o loss of precisionpublic int compare(Number x, Number y)
NumberSystemNumber values numerically.compare in interface NumberSystem0 if x == y;
a value less than 0 if x < y; and
a value greater than 0 if x > ypublic boolean isZero(Number number)
isZero in interface NumberSystempublic boolean isOne(Number number)
isOne in interface NumberSystempublic boolean isLessThanOne(Number number)
isLessThanOne in interface NumberSystempublic boolean isInteger(Number number)
NumberSystemnumber has fractional parts or not.isInteger in interface NumberSystemnumber represents a whole numberCopyright © 2005–2021 Units of Measurement project. All rights reserved.