KitchenSink v1.3.9 KitchenSink.Math View Source
Math functions!
Link to this section Summary
Types
Some functions allow us to specify something to return in a case which would normally raise an error. This type identifies that.
Functions
Numerical division which allows a specified return for "divide by zero."
Round down to the nearest multiple of significance.
Always round up to the nearest multiple of significance.
Link to this section Types
Some functions allow us to specify something to return in a case which would normally raise an error. This type identifies that.
Link to this section Functions
Link to this function
div(numerator, denominator, div_by_zero)
View Sourcediv(number(), number(), error_return()) :: number() | error_return()
Numerical division which allows a specified return for "divide by zero."
iex> div(1, 2, :oops)
0.5
iex> div(1, 0, :oops)
:oops
Round down to the nearest multiple of significance.
Parameters
- number: The number you wish to have rounded.
significance: The multiple to which you would like to round.
Must not be 0.
Examples:
iex> round_down_to_multiple(31, 5)
30
iex> round_down_to_multiple(29.49, 10)
20
Always round up to the nearest multiple of significance.
Parameters
- number: The number you wish to have rounded.
significance: The multiple to which you would like to round.
Must not be 0.
Examples:
iex> round_up_to_multiple(31, 5)
35
iex> round_up_to_multiple(29.49, 10)
30