Elixir v1.0.5 Integer

Functions for working with integers.

Summary

Functions

Converts a binary to an integer

Returns a char list which corresponds to the text representation of the given integer

Returns a char list which corresponds to the text representation of the given integer in the given case

Returns a binary which corresponds to the text representation of some_integer

Returns a binary which corresponds to the text representation of some_integer in base base

Macros

Determines if an integer is even

Determines if an integer is odd

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
to_char_list(number)

Specs

to_char_list(integer) :: char_list

Returns a char list which corresponds to the text representation of the given integer.

Inlined by the compiler.

Examples

iex> Integer.to_char_list(7)
'7'
to_char_list(number, base)

Specs

to_char_list(integer, 2 .. 36) :: char_list

Returns a char list which corresponds to the text representation of the given integer in the given case.

Inlined by the compiler.

Examples

iex> Integer.to_char_list(1023, 16)
'3FF'
to_string(some_integer)

Specs

to_string(integer) :: String.t

Returns a binary which corresponds to the text representation of some_integer.

Inlined by the compiler.

Examples

iex> Integer.to_string(123)
"123"
to_string(some_integer, base)

Specs

to_string(integer, 2 .. 36) :: String.t

Returns a binary which corresponds to the text representation of some_integer in base base.

Inlined by the compiler.

Examples

iex> Integer.to_string(100, 16)
"64"

Macros

is_even(n)

Determines if an integer is even.

Returns true if n is an even number, otherwise false.

Allowed in guard clauses.

is_odd(n)

Determines if an integer is odd.

Returns true if n is an odd number, otherwise false.

Allowed in guard clauses.