DarkMatter.Decimals.Conversion (DarkMatter v1.1.4) View Source
Decimal conversion functions
Link to this section Summary
Functions
Cast Decimal
Cast Decimal
Cast Decimal ok
((n + (factor/2)) / factor) * factor
Determine if a number is rounded.
Generic to integer function
Transform a t:stringable.t/0
into a normalized string.
Transform a t:stringable.t/0
into a normalized formatted string.
Link to this section Types
Specs
conversion_modes() :: :normal | :reduced
Specs
round_option() :: {:round_up, pos_integer()}
Specs
round_options() :: [round_option(), ...]
Specs
Specs
to_string_formatter() :: :usd
Link to this section Functions
Specs
cast_decimal(any(), conversion_modes()) :: :error | nil | Decimal.t()
Cast Decimal
Specs
cast_decimal!(any(), conversion_modes()) :: Decimal.t()
Cast Decimal
Specs
cast_decimal_ok(any(), conversion_modes()) :: {:ok, Decimal.t()} | :error
Cast Decimal ok
Specs
decimal_round_ok(any(), round_options()) :: {:ok, Decimal.t()} | :error
((n + (factor/2)) / factor) * factor
Specs
rounded?(any(), round_options()) :: boolean()
Determine if a number is rounded.
Specs
to_number(DarkMatter.maybe_numeric()) :: DarkMatter.maybe_number()
Generic to integer function
Specs
to_string(stringable()) :: String.t() | nil
Transform a t:stringable.t/0
into a normalized string.
Raises ArgumentError
if a given binary isn't a valid Decimal
.
Specs
to_string(stringable(), to_string_formatter()) :: String.t() | nil
Transform a t:stringable.t/0
into a normalized formatted string.
Raises ArgumentError
if a given binary isn't a valid Decimal
.