View Source Quantity.Sigils (Quantity v1.0.0)

Sigils related to Quantity and Decimal

Link to this section Summary

Functions

Construct a Decimal

Construct a Quantity

Link to this section Functions

@spec sigil_d(String.t(), []) :: Decimal.t()

Construct a Decimal

iex> ~d[12.340] Decimal.new("12.340")

@spec sigil_Q(String.t(), []) :: Quantity.t()

Construct a Quantity

iex> ~Q[12.340 kwh] Quantity.new(~d[12.340], "kwh")

iex> ~Q[15 $/banana] Quantity.new(~d[15], {:div, "$", "banana"})

iex> ~Q[12.34 m*m] Quantity.new(~d[12.34], {:mult, "m", "m"})