DarkMatter.Decimals.decimal_round_ok

You're seeing just the function decimal_round_ok, go back to DarkMatter.Decimals module for more information.
Link to this function

decimal_round_ok(x, opts)

View Source

Specs

decimal_round_ok(any(), DarkMatter.Decimals.Conversion.round_options()) ::
  {:ok, Decimal.t()} | :error

Rounds an x of type DarkMatter.numeric/0 based on the opts.

Returns round_up * ((x + (round_up/2)) / round_up)

Examples

iex> decimal_round_ok(25.11, round_up: 50)
{:ok, %Decimal{coef: 5, exp: 1}}

iex> decimal_round_ok(50, round_up: 50)
{:ok, %Decimal{coef: 5, exp: 1}}

iex> decimal_round_ok(0, round_up: 50)
{:ok, %Decimal{coef: 0, exp: 0}}