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