Elex.Quantity (Elex v0.3.0)

View Source

A measured value with a unit.

Evaluate returns %Elex.Quantity{} for unitful results. The :unit is an %Elex.Unit{} monomial (%{"N" => 1}, %{"m" => 2}, %{"m" => 1, "s" => -1}).

Fields

  • :value - The numeric magnitude as a Decimal.t()
  • :unit - An %Elex.Unit{}

Examples

%Elex.Quantity{value: Decimal.new("1.001"), unit: Elex.Unit.new!(%{"m" => 1})}
%Elex.Quantity{value: Decimal.new("10"), unit: Elex.Unit.new!(%{"m" => 1, "s" => -1})}

Summary

Types

t()

A quantity with a decimal magnitude and a unit.

An Elex.Unit carried by a quantity.

Types

t()

@type t() :: %Elex.Quantity{unit: unit(), value: Decimal.t()}

A quantity with a decimal magnitude and a unit.

unit()

@type unit() :: Elex.Unit.t()

An Elex.Unit carried by a quantity.