|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface NumberOperations<N extends Number>
Number operations is a collection of arithmetic and other operations usually supported by different number types.
| Method Summary | |
|---|---|
N |
abs(N number)
Returns the absolute value of the given number, i.e. |
N |
add(N numA,
N numB)
Returns the sum of the two values, i.e. |
int |
byteLength()
Returns the byte array length if toByteArray(Number) is used and if
this size is fixed, and -1 if the size may vary depending on the number
instance |
N |
divide(N numA,
N numB)
Returns the ratio of the two values, i.e. |
N |
fromByteArray(byte[] bytes)
Converts the byte array containing binary data into a new number instance. |
N |
invert(N number)
Returns the inverted value, i.e. |
boolean |
isNegative(N number)
Returns true if this value negative, i.e. |
boolean |
isNonNegative(N number)
Returns true if this value not negative, i.e. |
boolean |
isNonPositive(N number)
Returns true if this value not positive, i.e. |
boolean |
isNonZero(N number)
Returns true if this value is numerically unequal to zero, i.e. |
boolean |
isOne(N number)
Returns true if this value is numerically equal to one, i.e. |
boolean |
isPositive(N number)
Returns true if this value positive, i.e. |
boolean |
isZero(N number)
Returns true if this value is numerically equal to zero, i.e. |
N |
max(N... vals)
Returns the largest value of the given numbers, i.e. |
N |
max(N valA,
N valB)
Returns the larger value of the two numbers, i.e. |
N |
min(N... vals)
Returns the smallest value of the given numbers, i.e. |
N |
min(N valA,
N valB)
Returns the smaller value of the two numbers, i.e. |
N |
multiply(N numA,
N numB)
Returns the product of the two values, i.e. |
N |
negate(N number)
Returns the negated value, i.e. |
N[] |
newArray(int size)
Create a new array of the underlying number type |
N[][] |
newArray(int rows,
int cols)
Create a new 2 dimensional array of the underlying number type |
Class<N> |
numberClass()
The class representing numbers of this number operations instance |
N |
one()
Returns the value representing one |
N |
pow(N numA,
N numB)
Returns the powered value, i.e. |
N |
readFrom(DataInput in)
Reads binary data from the given data input. |
N |
reduce(N number)
Converts the number into some reduced form. |
N[] |
reduceVector(boolean cloneOnChange,
N... vector)
Converts a vector into some reduced form. |
int |
signum(N number)
Returns signum of the value, i.e. |
N |
subtract(N numA,
N numB)
Returns the difference of the two values, i.e. |
byte[] |
toByteArray(N number)
Converts this number to binary data and returns it as a byte array. |
N |
valueOf(double value)
Create an instance of the underlying number type based on the submitted double value |
N |
valueOf(long value)
Create an instance of the underlying number type based on the submitted long integer value |
N |
valueOf(Number n)
Create an instance of the underlying number type based on the submitted number |
N |
valueOf(String s)
Create an instance of the underlying number type based on the given string representation of the number |
void |
writeTo(N number,
DataOutput out)
Converts this number to binary data and writes it to the data output. |
N |
zero()
Returns the value representing zero |
| Methods inherited from interface java.util.Comparator |
|---|
compare, equals |
| Method Detail |
|---|
Class<N> numberClass()
N[] newArray(int size)
N[][] newArray(int rows,
int cols)
N valueOf(String s)
throws NumberFormatException
NumberFormatException - If converting the string to a number fails
N valueOf(Number n)
throws IllegalArgumentException
IllegalArgumentException - If converting into the underlying number
type fails or is not supported
N valueOf(long value)
throws IllegalArgumentException
IllegalArgumentException - If converting into the underlying number
type fails or is not supported
N valueOf(double value)
throws IllegalArgumentException
IllegalArgumentException - If converting into the underlying number
type fails or is not supportedN abs(N number)
N negate(N number)
N add(N numA,
N numB)
N subtract(N numA,
N numB)
N multiply(N numA,
N numB)
N divide(N numA,
N numB)
For integer types, an integer division is performed, ignoring possible remainders
N invert(N number)
throws IllegalArgumentException
IllegalArgumentException - If inversion of the value leads to a number
which cannot be converted to the underlying
number type
N pow(N numA,
N numB)
N zero()
N one()
N reduce(N number)
N[] reduceVector(boolean cloneOnChange,
N... vector)
Note that the vector length might change by this operation. If only
individual components of the vector should be reduced, which is not
affecting the vector's length, reduce each number
separately.
cloneOnChange - if a reduction can be made, the array is cloned
and the original array is not changed. If no
reduction can be made, or if cloneOnChange
is false, the original array will be returned,
unmodified in the former case, and with reduced
values in the latter case.vector - the vector to reduceint signum(N number)
boolean isOne(N number)
boolean isZero(N number)
boolean isNonZero(N number)
boolean isPositive(N number)
boolean isNonPositive(N number)
boolean isNegative(N number)
boolean isNonNegative(N number)
N max(N valA,
N valB)
N max(N... vals)
N min(N valA,
N valB)
N min(N... vals)
byte[] toByteArray(N number)
fromByteArray(byte[]) method.
N fromByteArray(byte[] bytes)
toByteArray(Number) method.
void writeTo(N number,
DataOutput out)
throws IOException
readFrom(DataInput).
IOException
N readFrom(DataInput in)
throws IOException
writeTo(Number, DataOutput)
IOExceptionint byteLength()
toByteArray(Number) is used and if
this size is fixed, and -1 if the size may vary depending on the number
instance
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||