numbers v5.0.1 Numbers.Protocols.Multiplication protocol
For supporting Numbers.mult/2
.
Link to this section Summary
Functions
Multiplies the two numbers together
Should return the ‘multiplicative identity’ of the same type as the argument. This is the value that can be added to another number, to let the result remain equal to that number
Link to this section Types
Link to this section Functions
Multiplies the two numbers together.
Should return the ‘multiplicative identity’ of the same type as the argument. This is the value that can be added to another number, to let the result remain equal to that number.
(For integers, this is 1
, for floats, 1.0
. Most other numeric types have their own ‘one’ variant as well.)
This should be defined so that:
a = some_num
mult(a, mult_id()) == a
mult(mult_id(), a) == a
If the numeric structure also implements Numbers.Protocols.Division
, the following should also be true:
a = some_num
div(a, mult_id()) == a
div(mult_id(), a) == a
(Note that it is fine if the result is not structurally identical, as long as it is logically equal.)