exmorph v0.1.0 Exmorph.Cast
Summary
Functions
Returns true or false, depending on if the passed string can be cast to a float
Returns true or false, depending on if the passed string can be cast to an integer
Converts a bitstring to a float. Throws an exception if the value cannot be cast
Converts a bitstring to an integer. Throws an exception if the value cannot be cast
Converts a bitstring to a float or integer. Returns the value in its original form if it cannot be cast
Functions
Returns true or false, depending on if the passed string can be cast to a float.
Examples
iex> Exmorph.Cast.matches_float?(".1")
true
iex> Exmorph.Cast.matches_float?("3.14159265359")
true
iex> Exmorph.Cast.matches_float?("12")
false
Returns true or false, depending on if the passed string can be cast to an integer.
Examples
iex> Exmorph.Cast.matches_integer?("32")
true
iex> Exmorph.Cast.matches_integer?("3.14159265359")
false
Converts a bitstring to a float. Throws an exception if the value cannot be cast.
Examples
iex> Exmorph.Cast.to_float(".1")
0.1
iex> Exmorph.Cast.to_float("3.14159265359")
3.14159265359