Quantity v0.2.0 Quantity View Source
A data structure that encapsulates a decimal value with a unit.
Link to this section Summary
Functions
Extracts the base value from the quantity
Extracts the exponent from the quantity
Builds a new Quantity from a Decimal and a unit
Builds a new Quantity from a base value, exponent and unit
Parses a string representation of a quantity (perhaps generated with to_string/1)
Same as parse/1, but errors if it could not parse
Encodes the quantity as a string. The result is parsable with parse/1 If the exponent is positive, encode usinge the "raw" format to preserve precision
Extracts the unit from the quantity
Link to this section Types
Link to this section Functions
See Quantity.Math.add/2.
See Quantity.Math.add!/2.
Extracts the base value from the quantity
Extracts the exponent from the quantity
Builds a new Quantity from a Decimal and a unit
Builds a new Quantity from a base value, exponent and unit
Parses a string representation of a quantity (perhaps generated with to_string/1)
Same as parse/1, but errors if it could not parse
See Quantity.Math.sub/2.
See Quantity.Math.sub!/2.
See Quantity.Math.sum/1.
See Quantity.Math.sum/3.
See Quantity.Math.sum!/1.
See Quantity.Math.sum!/3.
Encodes the quantity as a string. The result is parsable with parse/1 If the exponent is positive, encode usinge the "raw" format to preserve precision
iex> Quantity.new(42, -1, "db") |> Quantity.to_string() "4.2 db" iex> Quantity.new(42, 1, "db") |> Quantity.to_string() "42E1 db"
Extracts the unit from the quantity