cast to int elixir
Check Integer.parse/1 and Float.parse/1.
elixir string to integer
@spec parse(binary(), 2..36) ::
{integer(), remainder_of_binary :: binary()} | :error
Parses a text representation of an integer.
An optional base to the corresponding integer can be provided. If base is not
given, 10 will be used.
If successful, returns a tuple in the form of {integer, remainder_of_binary}.
Otherwise :error.
Raises an error if base is less than 2 or more than 36.
If you want to convert a string-formatted integer directly to an integer,
String.to_integer/1 or String.to_integer/2 can be used instead.
## Examples
iex> Integer.parse("34")
{34, ""}
iex> Integer.parse("34.5")
{34, ".5"}
iex> Integer.parse("three")
:error
iex> Integer.parse("34", 10)
{34, ""}
iex> Integer.parse("f4", 16)
{244, ""}
iex> Integer.parse("Awww++", 36)
{509216, "++"}
iex> Integer.parse("fab", 10)
:error
iex> Integer.parse("a2", 38)
** (ArgumentError) invalid base 38
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us