Skip to content

Instantly share code, notes, and snippets.

View noelworden's full-sized avatar

Noel Worden noelworden

View GitHub Profile
%{"kind": "less_than_or_equal_to", "number": 0, "validation": "number"}
%{"kind" => "less_than_or_equal_to", "number" => 0, "validation" => "number"}
iex> Map.to_list(%{"kind" => "less_than_or_equal_to", "number" => 0, "validation" => "number"})
[{"kind", "less_than_or_equal_to"}, {"number", 0}, {"validation", "number"}]
[kind: "less_than_or_equal_to", number: 0, validation: "number"]
@noelworden
noelworden / week_june15_casting02.ex
Last active July 17, 2020 23:32
#blog_snippets
iex> Decimal.mult(Decimal.cast("0.8"), 100)
#Decimal<80.0>
iex> Decimal.mult(Decimal.cast("0.87"), 100)
#Decimal<87.00>
@noelworden
noelworden / week_june15_casting03.ex
Last active July 17, 2020 23:33
#blog_snippets
iex> Decimal.round(Decimal.mult(Decimal.cast("0.8"), 100), 2)
#Decimal<80.00>
iex> Decimal.round(Decimal.mult(Decimal.cast("0.87"), 100), 2)
#Decimal<87.00>
@noelworden
noelworden / week_june15_casting04.ex
Last active July 17, 2020 23:33
#blog_snippets
iex> Decimal.to_string(Decimal.mult(Decimal.cast("0.8"), 100), :xsd)
"80.0"
iex> Decimal.to_string(Decimal.mult(Decimal.cast("0.87"), 100), :xsd)
"87.0"
@noelworden
noelworden / week_june15_casting05.ex
Last active July 17, 2020 23:33
#blog_snippets
iex> Decimal.mult(Decimal.cast("0.8700"), 100)
#Decimal<87.0000>
iex> Decimal.mult(Decimal.cast("0.8700000"), 100)
#Decimal<87.0000000>
@noelworden
noelworden / week_june15_casting06.ex
Last active July 17, 2020 23:34
#blog_snippets
iex> Decimal.to_string(Decimal.mult(Decimal.cast("0.8700000"), 100), :xsd)
"87.0"
@noelworden
noelworden / week_june15_casting08.ex
Last active July 17, 2020 23:34
#blog_snippets
iex> Decimal.to_string(Decimal.mult(Decimal.cast("0.8765309"), 100), :xsd)
"87.65309"