Provides an implicit additive commutative monoid implementation for the Number type.
This object defines the zero element and the plus operation for the Number type, conforming to the algebraic structure of an additive commutative monoid.
The zero element acts as the additive identity, and the plus operation is both associative and commutative, enabling addition of two Number instances.
The method determines the type of the given Number instances and performs the appropriate addition operation. It supports addition for Real, RationalNumber, and WholeNumber types. If the types are incompatible or cannot be converted to corresponding types, it throws a AlgebraException.
This method is marked as @tailrec to optimize recursive addition operations.
Value parameters
x
the first Number instance
y
the second Number instance
Attributes
Returns
a Number instance representing the result of the addition of x and y
Returns the additive identity element for the Number type.
Returns the additive identity element for the Number type.
This method provides the zero element, which serves as the neutral element in addition operations for instances of Number. Adding zero to any Number instance will result in the same Number instance.