Package dev.nm.number
Interface NumberUtils.Comparable<T extends Number>
-
- Type Parameters:
T
- a subclass ofNumber
- All Known Implementing Classes:
Complex
- Enclosing class:
- NumberUtils
public static interface NumberUtils.Comparable<T extends Number>
We need a precision parameter to determine whether two numbers are close enough to be treated as equal. All subclasses ofNumber
must implement this interface to work withNumberUtils.compare(java.lang.Number, java.lang.Number, double)
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
compare(Number that, double epsilon)
Comparethis
andthat
numbers up to a precision.
-
-
-
Method Detail
-
compare
int compare(Number that, double epsilon)
Comparethis
andthat
numbers up to a precision.- Parameters:
that
- aNumber
. As a number can be represented in multiple ways, e.g., 0 = 0 + 0i, the implementation may need to checkObject
type.epsilon
- a precision parameter: when a number |x| ≤ ε, it is considered 0- Returns:
- 0 if both numbers are close enough; +1 if
this
is bigger; -1 ifthat
is bigger
-
-