DefaultNumberSystempublic interface NumberSystem
Number operations on an implementation specific set of
Number types.
Let S be the set of possible Number values within the (given) set of
Number types.
Then S is closed
under the collection of NumberSystem's methods.
| Modifier and Type | Interface | Description |
|---|---|---|
static class |
NumberSystem.DivisionResult |
Immutable value type, holder of 2 numbers.
|
| Modifier and Type | Method | 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}
|
default boolean |
equals(Number x,
Number 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. |
Number add(Number x, Number y)
x and y as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.x - y - x + yNumber subtract(Number x, Number y)
x and y as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.x - y - x - yNumber multiply(Number x, Number y)
x and y as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.x - y - x * yNumber divide(Number x, Number y)
x and y as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.x - y - x / yNumber[] divideAndRemainder(Number x, Number y, boolean roundRemainderTowardsZero)
x - y - roundRemainderTowardsZero - - whether the division remainder should be rounded towards zeroNumber power(Number number, int exponent)
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 - exponent - - an integerArithmeticException - if number and exponent are ZERONumber reciprocal(Number number)
number as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.number - number^-1Number negate(Number number)
number as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.number - -numberint signum(Number number)
number.number - signum(number)Number abs(Number number)
number as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.number - abs(number)Number exp(Number number)
number as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.number - e^number, with e Euler's Constant)Number log(Number number)
number as a Number that best
represents the arithmetic result within the set of number types this NumberSystem
supports.number - Number narrow(Number number)
number 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.
number - number w/o loss of precisionint compare(Number x, Number y)
Number values numerically.x - y - 0 if x == y;
a value less than 0 if x < y; and
a value greater than 0 if x > yboolean isLessThanOne(Number number)
boolean isInteger(Number number)
number has fractional parts or not.number - number represents a whole numberCopyright © 2005–2023 Units of Measurement project. All rights reserved.