Integer
Functions for working with integers.
Summary
| even?(n) | Determines if an integer is even |
| odd?(n) | Determines if an integer is odd |
| parse(bin) | Converts a binary to an integer |
Functions
Specs:
- parse(binary) :: {integer, binary} | :error
Converts a binary to an integer.
If successful, returns a tuple of the form { integer, remainder_of_binary }.
Otherwise :error.
Examples
iex> Integer.parse("34")
{34,""}
iex> Integer.parse("34.5")
{34,".5"}
iex> Integer.parse("three")
:error
Macros
Determines if an integer is even.
Returns true if n is an even number, otherwise false.
Implemented as a macro so it is allowed in guard clauses.