numbers v5.0.0-rc0 Numbers.Protocols.Multiplication protocol

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

Types

t()
t() :: term

Functions

mult(a, b)
mult(t, t) :: t

Multiplies the two numbers together.

mult_id(term)
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.)