Numbers.Protocols.Multiplication protocol (numbers v5.2.4)

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

Specs

t() :: term()

Link to this section Functions

Specs

mult(t(), t()) :: t()

Multiplies the two numbers together.

Specs

mult_id(t()) :: t()

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.)