View Source Aja.Integer (Aja v0.6.5)
Some extra helper functions for working with integers,
that are not in the core Integer
module.
Summary
Functions
Format integers for humans, with thousand separators.
Examples
iex> Aja.Integer.decimal_format(1_234_567)
"1,234,567"
iex> Aja.Integer.decimal_format(-123)
"-123"
iex> Aja.Integer.decimal_format(-1_234, separator: ?_)
"-1_234"
@spec div_rem(integer(), pos_integer() | neg_integer()) :: {integer(), integer()}
Returns both the result of div/2
and rem/2
at once.
Examples
iex> Aja.Integer.div_rem(7, 3)
{2, 1}
iex> Aja.Integer.div_rem(-99, 2)
{-49, -1}
iex> Aja.Integer.div_rem(100, 0)
** (ArithmeticError) bad argument in arithmetic expression