NumberIsMultiplicativeGroup
An implicit object defining the multiplicative group structure for Number instances.
The NumberIsMultiplicativeGroup provides implementations for the methods required by the MultiplicativeGroup type class, enabling operations such as multiplication (times) and division (div) as well as access to the multiplicative identity (one). It supports a variety of Number subtypes, including Real, RationalNumber, and WholeNumber, and handles necessary conversions or raises exceptions when operations cannot be performed.
Attributes
- Graph
-
- Supertypes
- Self type
Members list
Value members
Concrete methods
Divides one Number by another and returns the resulting Number.
Divides one Number by another and returns the resulting Number.
This method performs safe division for different types of Number instances, such as Real. If the divisor is zero or an unsupported type is encountered, an exception is thrown.
Value parameters
- x
-
the numerator as a
Number - y
-
the denominator as a
Number
Attributes
- Returns
-
the result of dividing
xbyyas aNumber - Note
-
Throws an com.phasmidsoftware.number.algebra.util.AlgebraException if division by zero occurs or if the operation cannot be performed
Multiplies two Number instances and returns the resulting Number.
Multiplies two Number instances and returns the resulting Number.
This method performs multiplication between two instances of Number. The exact operation depends on the type of the input numbers, supporting various types such as Real, RationalNumber, and WholeNumber. If the types mismatch or a conversion between types is required, the appropriate logic is applied to carry out the multiplication. If the numbers cannot be multiplied due to an unsupported type or incorrect conversion, an exception is thrown.
Value parameters
- x
-
the first
Numberto be multiplied - y
-
the second
Numberto be multiplied
Attributes
- Returns
-
the result of multiplying
xandyas aNumber - Note
-
Throws an com.phasmidsoftware.number.algebra.util.AlgebraException if the multiplication is not possible for the given inputs
Inherited methods
Tests if a is one.
Tests if a is one.
Attributes
- Inherited from:
- MultiplicativeMonoid
Attributes
- Definition Classes
-
MultiplicativeGroup -> MultiplicativeMonoid -> MultiplicativeSemigroup
- Inherited from:
- MultiplicativeGroup
Attributes
- Definition Classes
-
MultiplicativeGroup -> MultiplicativeMonoid -> MultiplicativeSemigroup
- Inherited from:
- MultiplicativeGroup
Given a sequence of as, compute the product.
Given a sequence of as, compute the product.
Attributes
- Inherited from:
- MultiplicativeMonoid
Attributes
- Inherited from:
- MultiplicativeGroup
Given a sequence of as, combine them and return the total.
Given a sequence of as, combine them and return the total.
If the sequence is empty, returns None. Otherwise, returns Some(total).
Attributes
- Definition Classes
-
MultiplicativeMonoid -> MultiplicativeSemigroup
- Inherited from:
- MultiplicativeMonoid