PassiveSupport.Integer (passive_support v0.8.4)
Functions and guards for working with integers
Link to this section Summary
Functions
Arbitrary-precision exponentiation.
Arbitrary-precision factorial.
Converts an integer to a string, with a separator (default ",")
inserted, starting in from the right side of the number, spaced apart
by the number of digits specified by spacing (default 3).
Qualifies if integer is an integer less than 0.
Qualifies if integer is a natural number or 0.
Qualifies if integer is an integer greater than 0.
Returns the quotient and the remainder of dividend ÷ divisor
Link to this section Functions
exponential(base, exponent)
Specs
Arbitrary-precision exponentiation.
Will be deprecated by Elixir v1.12.0
Examples
iex> exponential(2, 10)
1024
iex> exponential(3, 3)
27
iex> exponential(2, 100)
1267650600228229401496703205376
iex> exponential(5, -3)
0.008
iex> exponential(9832, 0)
1
iex> exponential(0, 2)
0
iex> exponential(0, 0)
1
factorial(integer)
Specs
Arbitrary-precision factorial.
Examples
iex> factorial(5)
120
iex> factorial(6)
720
iex> factorial(-6)
-720
iex> factorial(1)
1
formatted(integer, opts \\ [])
Specs
Converts an integer to a string, with a separator (default ",")
inserted, starting in from the right side of the number, spaced apart
by the number of digits specified by spacing (default 3).
Examples
iex> formatted(57468291379)
"57,468,291,379"
iex> formatted(57468291379, separator: "_")
"57_468_291_379"
iex> formatted(57468291379, spacing: 4)
"574,6829,1379"
Qualifies if integer is an integer less than 0.
Qualifies if integer is a natural number or 0.
Qualifies if integer is an integer greater than 0.
(adhering to the mathematical principle that 0 is neither positive nor negative)
remdiv(dividend, divisor)
Specs
Returns the quotient and the remainder of dividend ÷ divisor
Examples
iex> remdiv(3, 2)
{1, 1}
iex> remdiv(-325, 60)
{-5, -25}
iex> remdiv(11, 3)
{3, 2}