Integer

Functions for working with integers.

Source

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

parse(bin)

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
Source

Macros

even?(n)

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.

Source
odd?(n)

Determines if an integer is odd.

Returns true if n is an odd number, otherwise false. Implemented as a macro so it is allowed in guard clauses.

Source