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, wait
equals
public DefaultNumberSystem()
public Number add(Number x, Number y)
NumberSystem
x
and y
as a Number
that best
represents the arithmetic result within the set of number types this NumberSystem
supports.add
in interface NumberSystem
x + y
public Number subtract(Number x, Number y)
NumberSystem
x
and y
as a Number
that best
represents the arithmetic result within the set of number types this NumberSystem
supports.subtract
in interface NumberSystem
x - y
public Number multiply(Number x, Number y)
NumberSystem
x
and y
as a Number
that best
represents the arithmetic result within the set of number types this NumberSystem
supports.multiply
in interface NumberSystem
x * y
public Number divide(Number x, Number y)
NumberSystem
x
and y
as a Number
that best
represents the arithmetic result within the set of number types this NumberSystem
supports.divide
in interface NumberSystem
x / y
public Number[] divideAndRemainder(Number x, Number y, boolean roundRemainderTowardsZero)
NumberSystem
divideAndRemainder
in interface NumberSystem
roundRemainderTowardsZero
- - whether the division remainder should be rounded towards zeropublic Number reciprocal(Number number)
NumberSystem
number
as a Number
that best
represents the arithmetic result within the set of number types this NumberSystem
supports.reciprocal
in interface NumberSystem
number^-1
public int signum(Number number)
NumberSystem
number
.signum
in interface NumberSystem
signum(number)
public Number abs(Number number)
NumberSystem
number
as a Number
that best
represents the arithmetic result within the set of number types this NumberSystem
supports.abs
in interface NumberSystem
abs(number)
public Number negate(Number number)
NumberSystem
number
as a Number
that best
represents the arithmetic result within the set of number types this NumberSystem
supports.negate
in interface NumberSystem
-number
public Number power(Number number, int exponent)
NumberSystem
number
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 NumberSystem
exponent
- - an integerpublic Number exp(Number number)
NumberSystem
number
as a Number
that best
represents the arithmetic result within the set of number types this NumberSystem
supports.exp
in interface NumberSystem
e
^number, with e
Euler's Constant)public Number log(Number number)
NumberSystem
number
as a Number
that best
represents the arithmetic result within the set of number types this NumberSystem
supports.log
in interface NumberSystem
public Number narrow(Number number)
NumberSystem
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.
narrow
in interface NumberSystem
number
w/o loss of precisionpublic int compare(Number x, Number y)
NumberSystem
Number
values numerically.compare
in interface NumberSystem
0
if x == y
;
a value less than 0
if x < y
; and
a value greater than 0
if x > y
public boolean isZero(Number number)
isZero
in interface NumberSystem
public boolean isOne(Number number)
isOne
in interface NumberSystem
public boolean isLessThanOne(Number number)
isLessThanOne
in interface NumberSystem
public boolean isInteger(Number number)
NumberSystem
number
has fractional parts or not.isInteger
in interface NumberSystem
number
represents a whole numberCopyright © 2005–2021 Units of Measurement project. All rights reserved.