Package org.apache.commons.numbers.core
Interface Addition<T>
- Type Parameters:
T
- Type of elements.
- All Known Subinterfaces:
NativeOperators<T>
- All Known Implementing Classes:
BigFraction
,DD
,FP64
,Fraction
public interface Addition<T>
Addition.
-
Method Summary
-
Method Details
-
add
Binary addition.- Parameters:
a
- Element.- Returns:
this + a
.
-
zero
T zero()Identity element.- Returns:
- the field element such that for all
a
,zero().add(a).equals(a)
istrue
.
-
negate
T negate()Additive inverse.- Returns:
-this
.
-
isZero
default boolean isZero()Check if this is a neutral element of addition, i.e.this.add(a)
returnsa
or an element representing the same value asa
.The default implementation calls
equals(zero())
. Implementations may want to employ more a efficient method. This may even be required if an implementation has multiple representations ofzero
and itsequals
method differentiates between them.- Returns:
true
ifthis
is a neutral element of addition.- Since:
- 1.2
- See Also:
-